OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 bool IsVideoContent(const ContentInfo* content) { | 1912 bool IsVideoContent(const ContentInfo* content) { |
1913 return IsMediaContentOfType(content, MEDIA_TYPE_VIDEO); | 1913 return IsMediaContentOfType(content, MEDIA_TYPE_VIDEO); |
1914 } | 1914 } |
1915 | 1915 |
1916 bool IsDataContent(const ContentInfo* content) { | 1916 bool IsDataContent(const ContentInfo* content) { |
1917 return IsMediaContentOfType(content, MEDIA_TYPE_DATA); | 1917 return IsMediaContentOfType(content, MEDIA_TYPE_DATA); |
1918 } | 1918 } |
1919 | 1919 |
1920 const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, | 1920 const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, |
1921 MediaType media_type) { | 1921 MediaType media_type) { |
1922 for (ContentInfos::const_iterator content = contents.begin(); | 1922 for (const ContentInfo& content : contents) { |
1923 content != contents.end(); content++) { | 1923 if (IsMediaContentOfType(&content, media_type)) { |
1924 if (IsMediaContentOfType(&*content, media_type)) { | 1924 return &content; |
1925 return &*content; | |
1926 } | 1925 } |
1927 } | 1926 } |
1928 return nullptr; | 1927 return nullptr; |
1929 } | 1928 } |
1930 | 1929 |
1931 const ContentInfo* GetFirstAudioContent(const ContentInfos& contents) { | 1930 const ContentInfo* GetFirstAudioContent(const ContentInfos& contents) { |
1932 return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO); | 1931 return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO); |
1933 } | 1932 } |
1934 | 1933 |
1935 const ContentInfo* GetFirstVideoContent(const ContentInfos& contents) { | 1934 const ContentInfo* GetFirstVideoContent(const ContentInfos& contents) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 return static_cast<const VideoContentDescription*>( | 1978 return static_cast<const VideoContentDescription*>( |
1980 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 1979 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
1981 } | 1980 } |
1982 | 1981 |
1983 const DataContentDescription* GetFirstDataContentDescription( | 1982 const DataContentDescription* GetFirstDataContentDescription( |
1984 const SessionDescription* sdesc) { | 1983 const SessionDescription* sdesc) { |
1985 return static_cast<const DataContentDescription*>( | 1984 return static_cast<const DataContentDescription*>( |
1986 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 1985 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
1987 } | 1986 } |
1988 | 1987 |
| 1988 // |
| 1989 // Non-const versions of the above functions. |
| 1990 // |
| 1991 |
| 1992 ContentInfo* GetFirstMediaContent(ContentInfos& contents, |
| 1993 MediaType media_type) { |
| 1994 for (ContentInfo& content : contents) { |
| 1995 if (IsMediaContentOfType(&content, media_type)) { |
| 1996 return &content; |
| 1997 } |
| 1998 } |
| 1999 return nullptr; |
| 2000 } |
| 2001 |
| 2002 ContentInfo* GetFirstAudioContent(ContentInfos& contents) { |
| 2003 return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO); |
| 2004 } |
| 2005 |
| 2006 ContentInfo* GetFirstVideoContent(ContentInfos& contents) { |
| 2007 return GetFirstMediaContent(contents, MEDIA_TYPE_VIDEO); |
| 2008 } |
| 2009 |
| 2010 ContentInfo* GetFirstDataContent(ContentInfos& contents) { |
| 2011 return GetFirstMediaContent(contents, MEDIA_TYPE_DATA); |
| 2012 } |
| 2013 |
| 2014 static ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, |
| 2015 MediaType media_type) { |
| 2016 if (sdesc == nullptr) { |
| 2017 return nullptr; |
| 2018 } |
| 2019 |
| 2020 return GetFirstMediaContent(sdesc->contents(), media_type); |
| 2021 } |
| 2022 |
| 2023 ContentInfo* GetFirstAudioContent(SessionDescription* sdesc) { |
| 2024 return GetFirstMediaContent(sdesc, MEDIA_TYPE_AUDIO); |
| 2025 } |
| 2026 |
| 2027 ContentInfo* GetFirstVideoContent(SessionDescription* sdesc) { |
| 2028 return GetFirstMediaContent(sdesc, MEDIA_TYPE_VIDEO); |
| 2029 } |
| 2030 |
| 2031 ContentInfo* GetFirstDataContent(SessionDescription* sdesc) { |
| 2032 return GetFirstMediaContent(sdesc, MEDIA_TYPE_DATA); |
| 2033 } |
| 2034 |
| 2035 MediaContentDescription* GetFirstMediaContentDescription( |
| 2036 SessionDescription* sdesc, |
| 2037 MediaType media_type) { |
| 2038 ContentInfo* content = GetFirstMediaContent(sdesc, media_type); |
| 2039 ContentDescription* description = content ? content->description : NULL; |
| 2040 return static_cast<MediaContentDescription*>(description); |
| 2041 } |
| 2042 |
| 2043 AudioContentDescription* GetFirstAudioContentDescription( |
| 2044 SessionDescription* sdesc) { |
| 2045 return static_cast<AudioContentDescription*>( |
| 2046 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_AUDIO)); |
| 2047 } |
| 2048 |
| 2049 VideoContentDescription* GetFirstVideoContentDescription( |
| 2050 SessionDescription* sdesc) { |
| 2051 return static_cast<VideoContentDescription*>( |
| 2052 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
| 2053 } |
| 2054 |
| 2055 DataContentDescription* GetFirstDataContentDescription( |
| 2056 SessionDescription* sdesc) { |
| 2057 return static_cast<DataContentDescription*>( |
| 2058 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| 2059 } |
| 2060 |
1989 } // namespace cricket | 2061 } // namespace cricket |
OLD | NEW |