Ejemplo n.º 1
0
WebRtc_UWord8
TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecID_B)
{
    AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
    WebRtc_UWord8 noCodec = tmpACM->NumberOfCodecs();
    CodecInst codecInst;
    printf("List of Supported Codecs\n");
    printf("========================\n");
    for(WebRtc_UWord8 codecCntr = 0; codecCntr < noCodec; codecCntr++)
    {
        tmpACM->Codec(codecCntr, codecInst);
        printf("%d- %s\n", codecCntr, codecInst.plname);
    }
    printf("\nChoose a send codec for side A [0]: ");
    char myStr[15] = "";
    fgets(myStr, 10, stdin);
    *codecID_A = (WebRtc_UWord8)atoi(myStr);

    printf("\nChoose a send codec for side B [0]: ");
    fgets(myStr, 10, stdin);
    *codecID_B = (WebRtc_UWord8)atoi(myStr);

    AudioCodingModule::Destroy(tmpACM);
    printf("\n");
    return 0;
}
Ejemplo n.º 2
0
static pj_status_t webrtc_enum_codecs(pjmedia_codec_factory *factory,
		unsigned *count, pjmedia_codec_info codecs[]) {
	unsigned max;
	unsigned i;
	int numCodecs = 1;

	PJ_UNUSED_ARG(factory);
	PJ_ASSERT_RETURN(codecs && *count > 0, PJ_EINVAL);

	max = *count;

	// TODO : we could use AudioCodingModule::RegisterReceiveCodec / UnRegister... in order to change PT
	AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
	struct CodecInst sendCodecTmp;
	numCodecs = acmTmp->NumberOfCodecs();

	PJ_LOG(4, (THIS_FILE, "List of supported codec."));

	for (i = 0, *count = 0; i < numCodecs && *count < max; ++i) {

		acmTmp->Codec(i, sendCodecTmp);
		pj_str_t codec_name = pj_str((char*) sendCodecTmp.plname);

		// Exclude useless codecs
		if ((pj_stricmp2(&codec_name, "telephone-event") != 0)
				&& (pj_stricmp2(&codec_name, "cn") != 0)
				/* Exclude PCMU/PCMA cause already in pjsip and wertc force that to be built in*/
				&& (pj_stricmp2(&codec_name, "pcmu") != 0)
				&& (pj_stricmp2(&codec_name, "pcma") != 0)
		) {
			PJ_LOG(
					4,
					(THIS_FILE, "%d %s %d %d %d %d", i, sendCodecTmp.plname, sendCodecTmp.pltype, sendCodecTmp.plfreq, sendCodecTmp.pacsize, sendCodecTmp.rate));

			pj_bzero(&codecs[*count], sizeof(pjmedia_codec_info));
			pj_strdup2(webrtc_factory.pool, &codecs[*count].encoding_name,
					sendCodecTmp.plname);
			codecs[*count].pt = sendCodecTmp.pltype;
			codecs[*count].type = PJMEDIA_TYPE_AUDIO;
			codecs[*count].clock_rate = sendCodecTmp.plfreq;
			codecs[*count].channel_cnt = sendCodecTmp.channels;

			++*count;
		}
	}

	AudioCodingModule::Destroy(acmTmp);

	return PJ_SUCCESS;
}
Ejemplo n.º 3
0
void EncodeToFileTest::Perform(int fileType, int codeId, int* codePars, int testMode)
{
    AudioCodingModule *acm = AudioCodingModule::Create(0);
    RTPFile rtpFile;
    char fileName[] = "outFile.rtp";
    rtpFile.Open(fileName, "wb+");
    rtpFile.WriteHeader();

    //for auto_test and logging
    _sender.testMode = testMode;
    _sender.codeId = codeId;

    _sender.Setup(acm, &rtpFile);
    struct CodecInst sendCodecInst;
    if(acm->SendCodec(sendCodecInst) >= 0)
    {
        _sender.Run();
    }
    _sender.Teardown();
    rtpFile.Close();
    AudioCodingModule::Destroy(acm);
}