OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 return static_cast<const VideoContentDescription*>( | 1901 return static_cast<const VideoContentDescription*>( |
1902 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 1902 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
1903 } | 1903 } |
1904 | 1904 |
1905 const DataContentDescription* GetFirstDataContentDescription( | 1905 const DataContentDescription* GetFirstDataContentDescription( |
1906 const SessionDescription* sdesc) { | 1906 const SessionDescription* sdesc) { |
1907 return static_cast<const DataContentDescription*>( | 1907 return static_cast<const DataContentDescription*>( |
1908 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 1908 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
1909 } | 1909 } |
1910 | 1910 |
| 1911 bool GetMediaChannelNameFromComponent( |
| 1912 int component, MediaType media_type, std::string* channel_name) { |
| 1913 if (media_type == MEDIA_TYPE_AUDIO) { |
| 1914 if (component == ICE_CANDIDATE_COMPONENT_RTP) { |
| 1915 *channel_name = GICE_CHANNEL_NAME_RTP; |
| 1916 return true; |
| 1917 } else if (component == ICE_CANDIDATE_COMPONENT_RTCP) { |
| 1918 *channel_name = GICE_CHANNEL_NAME_RTCP; |
| 1919 return true; |
| 1920 } |
| 1921 } else if (media_type == MEDIA_TYPE_VIDEO) { |
| 1922 if (component == ICE_CANDIDATE_COMPONENT_RTP) { |
| 1923 *channel_name = GICE_CHANNEL_NAME_VIDEO_RTP; |
| 1924 return true; |
| 1925 } else if (component == ICE_CANDIDATE_COMPONENT_RTCP) { |
| 1926 *channel_name = GICE_CHANNEL_NAME_VIDEO_RTCP; |
| 1927 return true; |
| 1928 } |
| 1929 } else if (media_type == MEDIA_TYPE_DATA) { |
| 1930 if (component == ICE_CANDIDATE_COMPONENT_RTP) { |
| 1931 *channel_name = GICE_CHANNEL_NAME_DATA_RTP; |
| 1932 return true; |
| 1933 } else if (component == ICE_CANDIDATE_COMPONENT_RTCP) { |
| 1934 *channel_name = GICE_CHANNEL_NAME_DATA_RTCP; |
| 1935 return true; |
| 1936 } |
| 1937 } |
| 1938 |
| 1939 return false; |
| 1940 } |
| 1941 |
| 1942 bool GetMediaComponentFromChannelName( |
| 1943 const std::string& channel_name, int* component) { |
| 1944 if (channel_name == GICE_CHANNEL_NAME_RTP || |
| 1945 channel_name == GICE_CHANNEL_NAME_VIDEO_RTP || |
| 1946 channel_name == GICE_CHANNEL_NAME_DATA_RTP) { |
| 1947 *component = ICE_CANDIDATE_COMPONENT_RTP; |
| 1948 return true; |
| 1949 } else if (channel_name == GICE_CHANNEL_NAME_RTCP || |
| 1950 channel_name == GICE_CHANNEL_NAME_VIDEO_RTCP || |
| 1951 channel_name == GICE_CHANNEL_NAME_DATA_RTP) { |
| 1952 *component = ICE_CANDIDATE_COMPONENT_RTCP; |
| 1953 return true; |
| 1954 } |
| 1955 |
| 1956 return false; |
| 1957 } |
| 1958 |
| 1959 bool GetMediaTypeFromChannelName( |
| 1960 const std::string& channel_name, MediaType* media_type) { |
| 1961 if (channel_name == GICE_CHANNEL_NAME_RTP || |
| 1962 channel_name == GICE_CHANNEL_NAME_RTCP) { |
| 1963 *media_type = MEDIA_TYPE_AUDIO; |
| 1964 return true; |
| 1965 } else if (channel_name == GICE_CHANNEL_NAME_VIDEO_RTP || |
| 1966 channel_name == GICE_CHANNEL_NAME_VIDEO_RTCP) { |
| 1967 *media_type = MEDIA_TYPE_VIDEO; |
| 1968 return true; |
| 1969 } else if (channel_name == GICE_CHANNEL_NAME_DATA_RTP || |
| 1970 channel_name == GICE_CHANNEL_NAME_DATA_RTCP) { |
| 1971 *media_type = MEDIA_TYPE_DATA; |
| 1972 return true; |
| 1973 } |
| 1974 |
| 1975 return false; |
| 1976 } |
| 1977 |
1911 } // namespace cricket | 1978 } // namespace cricket |
OLD | NEW |