Exemplo n.º 1
0
Variant SDP::GetAudioTrack(uint32_t index, string uri) {
	//1. Find the track
	Variant track = GetTrack(index, "audio");
	if (track == V_NULL) {
		FATAL("Audio track index %u not found", index);
		return Variant();
	}

	//2. Prepare the info
	Variant result;
	SDP_AUDIO_SERVER_IP(result) = (*this)[SDP_SESSION][SDP_O]["address"];
	string control = track[SDP_A].GetValue("control", false);
	if (control.find("rtsp") == 0)
		SDP_AUDIO_CONTROL_URI(result) = control;
	else
		SDP_AUDIO_CONTROL_URI(result) = uri + "/" + control;
	SDP_AUDIO_CODEC(result) = track[SDP_A].GetValue("rtpmap", false)["encodingName"];
	if ((uint64_t) SDP_AUDIO_CODEC(result) != CODEC_AUDIO_AAC) {
		FATAL("The only supported audio codec is aac");
		return Variant();
	}

	SDP_AUDIO_CODEC_SETUP(result) = track[SDP_A]
			.GetValue("fmtp", false)
			.GetValue("config", false);
	SDP_TRACK_GLOBAL_INDEX(result) = SDP_TRACK_GLOBAL_INDEX(track);
	SDP_TRACK_IS_AUDIO(result) = (bool)true;

	//3. Done
	return result;
}
Exemplo n.º 2
0
Variant SDP::GetAudioTrack(uint32_t index, string contentBase) {
	//1. Find the track
	Variant track = GetTrack(index, "audio");
	if (track == V_NULL) {
		FATAL("Audio track index %u not found", index);
		return Variant();
	}

	//2. Prepare the info
	Variant result;
	SDP_AUDIO_SERVER_IP(result) = (*this)[SDP_SESSION][SDP_O]["address"];
	string control = track[SDP_A].GetValue("control", false);
	if (control.find("rtsp") == 0) {
		SDP_AUDIO_CONTROL_URI(result) = control;
	} else {
		if ((contentBase != "") && (contentBase[contentBase.size() - 1] != '/')) {
			contentBase += "/";
		}
		SDP_AUDIO_CONTROL_URI(result) = contentBase + control;
	}
	SDP_AUDIO_CODEC(result) = track[SDP_A].GetValue("rtpmap", false)["encodingName"];
	if ((uint64_t) SDP_AUDIO_CODEC(result) != CODEC_AUDIO_AAC) {
		FATAL("The only supported audio codec is aac");
		return Variant();
	}

	SDP_AUDIO_CODEC_SETUP(result) = track[SDP_A]
			.GetValue("fmtp", false)
			.GetValue("config", false);
	SDP_AUDIO_TRANSPORT(result) = track[SDP_A].GetValue("rtpmap", false)["encodingNameString"];
	SDP_TRACK_GLOBAL_INDEX(result) = SDP_TRACK_GLOBAL_INDEX(track);
	SDP_TRACK_IS_AUDIO(result) = (bool)true;
	if (track.HasKeyChain(V_UINT32, false, 1, SDP_B))
		SDP_TRACK_BANDWIDTH(result) = track[SDP_B];
	else
		SDP_TRACK_BANDWIDTH(result) = (uint32_t) 0;

	SDP_TRACK_CLOCKRATE(result) = track[SDP_A].GetValue("rtpmap", false)["clockRate"];
	//3. Done
	return result;
}