| Index: webrtc/pc/mediasession.cc
|
| diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc
|
| index 52abfe855f6aef47fa83d7e1ce51321f090a2417..0fa20d8bd5d292990bf68fbc3899741b56491cd0 100644
|
| --- a/webrtc/pc/mediasession.cc
|
| +++ b/webrtc/pc/mediasession.cc
|
| @@ -1919,10 +1919,9 @@ bool IsDataContent(const ContentInfo* content) {
|
|
|
| const ContentInfo* GetFirstMediaContent(const ContentInfos& contents,
|
| MediaType media_type) {
|
| - for (ContentInfos::const_iterator content = contents.begin();
|
| - content != contents.end(); content++) {
|
| - if (IsMediaContentOfType(&*content, media_type)) {
|
| - return &*content;
|
| + for (const ContentInfo& content : contents) {
|
| + if (IsMediaContentOfType(&content, media_type)) {
|
| + return &content;
|
| }
|
| }
|
| return nullptr;
|
| @@ -1986,4 +1985,77 @@ const DataContentDescription* GetFirstDataContentDescription(
|
| GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
|
| }
|
|
|
| +//
|
| +// Non-const versions of the above functions.
|
| +//
|
| +
|
| +ContentInfo* GetFirstMediaContent(ContentInfos& contents,
|
| + MediaType media_type) {
|
| + for (ContentInfo& content : contents) {
|
| + if (IsMediaContentOfType(&content, media_type)) {
|
| + return &content;
|
| + }
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| +ContentInfo* GetFirstAudioContent(ContentInfos& contents) {
|
| + return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO);
|
| +}
|
| +
|
| +ContentInfo* GetFirstVideoContent(ContentInfos& contents) {
|
| + return GetFirstMediaContent(contents, MEDIA_TYPE_VIDEO);
|
| +}
|
| +
|
| +ContentInfo* GetFirstDataContent(ContentInfos& contents) {
|
| + return GetFirstMediaContent(contents, MEDIA_TYPE_DATA);
|
| +}
|
| +
|
| +static ContentInfo* GetFirstMediaContent(SessionDescription* sdesc,
|
| + MediaType media_type) {
|
| + if (sdesc == nullptr) {
|
| + return nullptr;
|
| + }
|
| +
|
| + return GetFirstMediaContent(sdesc->contents(), media_type);
|
| +}
|
| +
|
| +ContentInfo* GetFirstAudioContent(SessionDescription* sdesc) {
|
| + return GetFirstMediaContent(sdesc, MEDIA_TYPE_AUDIO);
|
| +}
|
| +
|
| +ContentInfo* GetFirstVideoContent(SessionDescription* sdesc) {
|
| + return GetFirstMediaContent(sdesc, MEDIA_TYPE_VIDEO);
|
| +}
|
| +
|
| +ContentInfo* GetFirstDataContent(SessionDescription* sdesc) {
|
| + return GetFirstMediaContent(sdesc, MEDIA_TYPE_DATA);
|
| +}
|
| +
|
| +MediaContentDescription* GetFirstMediaContentDescription(
|
| + SessionDescription* sdesc,
|
| + MediaType media_type) {
|
| + ContentInfo* content = GetFirstMediaContent(sdesc, media_type);
|
| + ContentDescription* description = content ? content->description : NULL;
|
| + return static_cast<MediaContentDescription*>(description);
|
| +}
|
| +
|
| +AudioContentDescription* GetFirstAudioContentDescription(
|
| + SessionDescription* sdesc) {
|
| + return static_cast<AudioContentDescription*>(
|
| + GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_AUDIO));
|
| +}
|
| +
|
| +VideoContentDescription* GetFirstVideoContentDescription(
|
| + SessionDescription* sdesc) {
|
| + return static_cast<VideoContentDescription*>(
|
| + GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
|
| +}
|
| +
|
| +DataContentDescription* GetFirstDataContentDescription(
|
| + SessionDescription* sdesc) {
|
| + return static_cast<DataContentDescription*>(
|
| + GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
|
| +}
|
| +
|
| } // namespace cricket
|
|
|