WebRTC: merge ICE sessions in into a single ICE session for all tracks
This commit is contained in:
parent
729b75ac2a
commit
a5d092c768
3 changed files with 23 additions and 18 deletions
|
@ -803,8 +803,8 @@ namespace SDP{
|
|||
return (m != NULL) ? true : false;
|
||||
}
|
||||
|
||||
bool Answer::enableVideo(const std::string &codecName){
|
||||
if (!enableMedia("video", codecName, answerVideoMedia, answerVideoFormat)){
|
||||
bool Answer::enableVideo(const std::string &codecName, SDP::Session &sdpSession){
|
||||
if (!enableMedia("video", codecName, answerVideoMedia, answerVideoFormat, sdpSession)){
|
||||
DONTEVEN_MSG("Failed to enable video.");
|
||||
return false;
|
||||
}
|
||||
|
@ -812,8 +812,8 @@ namespace SDP{
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Answer::enableAudio(const std::string &codecName){
|
||||
if (!enableMedia("audio", codecName, answerAudioMedia, answerAudioFormat)){
|
||||
bool Answer::enableAudio(const std::string &codecName, SDP::Session &sdpSession){
|
||||
if (!enableMedia("audio", codecName, answerAudioMedia, answerAudioFormat, sdpSession)){
|
||||
DONTEVEN_MSG("Not enabling audio.");
|
||||
return false;
|
||||
}
|
||||
|
@ -821,8 +821,8 @@ namespace SDP{
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Answer::enableMeta(const std::string &codecName){
|
||||
if (!enableMedia("meta", codecName, answerMetaMedia, answerMetaFormat)){
|
||||
bool Answer::enableMeta(const std::string &codecName, SDP::Session &sdpSession){
|
||||
if (!enableMedia("meta", codecName, answerMetaMedia, answerMetaFormat, sdpSession)){
|
||||
DONTEVEN_MSG("Not enabling meta.");
|
||||
return false;
|
||||
}
|
||||
|
@ -1100,7 +1100,7 @@ namespace SDP{
|
|||
// support; we select the first
|
||||
// one that we find.
|
||||
bool Answer::enableMedia(const std::string &type, const std::string &codecList,
|
||||
SDP::Media &outMedia, SDP::MediaFormat &outFormat){
|
||||
SDP::Media &outMedia, SDP::MediaFormat &outFormat, SDP::Session &sdpSession){
|
||||
Media *media = sdpOffer.getMediaForType(type);
|
||||
if (!media){
|
||||
INFO_MSG("Cannot enable %s codec; offer doesn't have %s media.", codecList.c_str(), type.c_str());
|
||||
|
@ -1168,8 +1168,13 @@ namespace SDP{
|
|||
outMedia = *media;
|
||||
outFormat = *format;
|
||||
outFormat.rtcpFormats.clear();
|
||||
outFormat.icePwd = generateIcePwd();
|
||||
outFormat.iceUFrag = generateIceUFrag();
|
||||
if (!sdpSession.icePwd.size()){
|
||||
sdpSession.icePwd = generateIcePwd();
|
||||
sdpSession.iceUFrag = generateIceUFrag();
|
||||
}
|
||||
outFormat.icePwd = sdpSession.icePwd;
|
||||
outFormat.iceUFrag = sdpSession.iceUFrag;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,9 +165,9 @@ namespace SDP{
|
|||
bool parseOffer(const std::string &sdp);
|
||||
bool hasVideo(); ///< Check if the offer has video.
|
||||
bool hasAudio(); ///< Check if the offer has audio.
|
||||
bool enableVideo(const std::string &codecName);
|
||||
bool enableAudio(const std::string &codecName);
|
||||
bool enableMeta(const std::string &codecName);
|
||||
bool enableVideo(const std::string &codecName, SDP::Session &sdpSession);
|
||||
bool enableAudio(const std::string &codecName, SDP::Session &sdpSession);
|
||||
bool enableMeta(const std::string &codecName, SDP::Session &sdpSession);
|
||||
void setCandidate(const std::string &ip, uint16_t port);
|
||||
void setFingerprint(const std::string &fingerprintSha); ///< Set the SHA265 that represents the
|
||||
///< certificate that is used with DTLS.
|
||||
|
@ -178,7 +178,7 @@ namespace SDP{
|
|||
|
||||
private:
|
||||
bool enableMedia(const std::string &type, const std::string &codecName, SDP::Media &outMedia,
|
||||
SDP::MediaFormat &outFormat);
|
||||
SDP::MediaFormat &outFormat, SDP::Session &sdpSession);
|
||||
void addLine(const std::string fmt, ...);
|
||||
std::string generateSessionId();
|
||||
std::string generateIceUFrag(); ///< Generates the `ice-ufrag` value.
|
||||
|
|
|
@ -773,7 +773,7 @@ namespace Mist{
|
|||
|
||||
// setup video WebRTC Track.
|
||||
if (vidTrack != INVALID_TRACK_ID){
|
||||
if (sdpAnswer.enableVideo(M.getCodec(vidTrack))){
|
||||
if (sdpAnswer.enableVideo(M.getCodec(vidTrack), sdpSession)){
|
||||
WebRTCTrack &videoTrack = webrtcTracks[vidTrack];
|
||||
if (!createWebRTCTrackFromAnswer(sdpAnswer.answerVideoMedia, sdpAnswer.answerVideoFormat, videoTrack)){
|
||||
FAIL_MSG("Failed to create the WebRTCTrack for the selected video.");
|
||||
|
@ -791,7 +791,7 @@ namespace Mist{
|
|||
|
||||
// setup audio WebRTC Track
|
||||
if (audTrack != INVALID_TRACK_ID){
|
||||
if (sdpAnswer.enableAudio(M.getCodec(audTrack))){
|
||||
if (sdpAnswer.enableAudio(M.getCodec(audTrack), sdpSession)){
|
||||
WebRTCTrack &audioTrack = webrtcTracks[audTrack];
|
||||
if (!createWebRTCTrackFromAnswer(sdpAnswer.answerAudioMedia, sdpAnswer.answerAudioFormat, audioTrack)){
|
||||
FAIL_MSG("Failed to create the WebRTCTrack for the selected audio.");
|
||||
|
@ -804,7 +804,7 @@ namespace Mist{
|
|||
|
||||
// setup meta WebRTC Track
|
||||
if (metaTrack != INVALID_TRACK_ID){
|
||||
if (sdpAnswer.enableMeta(M.getCodec(metaTrack))){
|
||||
if (sdpAnswer.enableMeta(M.getCodec(metaTrack), sdpSession)){
|
||||
WebRTCTrack &mTrack = webrtcTracks[metaTrack];
|
||||
if (!createWebRTCTrackFromAnswer(sdpAnswer.answerMetaMedia, sdpAnswer.answerMetaFormat, mTrack)){
|
||||
FAIL_MSG("Failed to create the WebRTCTrack for the selected metadata.");
|
||||
|
@ -989,7 +989,7 @@ namespace Mist{
|
|||
meta.reInit(streamName, false);
|
||||
|
||||
// video
|
||||
if (sdpAnswer.enableVideo(prefVideoCodec)){
|
||||
if (sdpAnswer.enableVideo(prefVideoCodec, sdpSession)){
|
||||
|
||||
size_t vIdx = meta.addDelayedTrack();
|
||||
if (!sdpAnswer.setupVideoDTSCTrack(meta, vIdx)){
|
||||
|
@ -1028,7 +1028,7 @@ namespace Mist{
|
|||
}
|
||||
|
||||
// audio setup
|
||||
if (sdpAnswer.enableAudio(prefAudioCodec)){
|
||||
if (sdpAnswer.enableAudio(prefAudioCodec, sdpSession)){
|
||||
|
||||
size_t aIdx = meta.addDelayedTrack();
|
||||
if (!sdpAnswer.setupAudioDTSCTrack(meta, aIdx)){
|
||||
|
|
Loading…
Add table
Reference in a new issue