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