OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 // Used by PeerConnectionFactory to create a media engine passed into | 62 // Used by PeerConnectionFactory to create a media engine passed into |
63 // ChannelManager. | 63 // ChannelManager. |
64 MediaEngineInterface* WebRtcMediaEngineFactory::Create( | 64 MediaEngineInterface* WebRtcMediaEngineFactory::Create( |
65 webrtc::AudioDeviceModule* adm, | 65 webrtc::AudioDeviceModule* adm, |
66 WebRtcVideoEncoderFactory* encoder_factory, | 66 WebRtcVideoEncoderFactory* encoder_factory, |
67 WebRtcVideoDecoderFactory* decoder_factory) { | 67 WebRtcVideoDecoderFactory* decoder_factory) { |
68 return CreateWebRtcMediaEngine(adm, encoder_factory, decoder_factory); | 68 return CreateWebRtcMediaEngine(adm, encoder_factory, decoder_factory); |
69 } | 69 } |
70 | 70 |
| 71 const char* kBweExtensionPriorities[] = { |
| 72 kRtpTransportSequenceNumberHeaderExtension, |
| 73 kRtpAbsoluteSenderTimeHeaderExtension, kRtpTimestampOffsetHeaderExtension}; |
| 74 |
| 75 const size_t kBweExtensionPrioritiesLength = |
| 76 ARRAY_SIZE(kBweExtensionPriorities); |
| 77 |
| 78 int GetPriority(const RtpHeaderExtension& extension, |
| 79 const char* extension_prios[], |
| 80 size_t extension_prios_length) { |
| 81 for (size_t i = 0; i < extension_prios_length; ++i) { |
| 82 if (extension.uri == extension_prios[i]) |
| 83 return static_cast<int>(i); |
| 84 } |
| 85 return -1; |
| 86 } |
| 87 |
| 88 std::vector<RtpHeaderExtension> FilterRedundantRtpExtensions( |
| 89 const std::vector<RtpHeaderExtension>& extensions, |
| 90 const char* extension_prios[], |
| 91 size_t extension_prios_length) { |
| 92 if (extensions.empty()) |
| 93 return std::vector<RtpHeaderExtension>(); |
| 94 std::vector<RtpHeaderExtension> filtered; |
| 95 std::map<int, const RtpHeaderExtension*> sorted; |
| 96 for (auto& extension : extensions) { |
| 97 int priority = |
| 98 GetPriority(extension, extension_prios, extension_prios_length); |
| 99 if (priority == -1) { |
| 100 filtered.push_back(extension); |
| 101 continue; |
| 102 } else { |
| 103 sorted[priority] = &extension; |
| 104 } |
| 105 } |
| 106 if (!sorted.empty()) |
| 107 filtered.push_back(*sorted.begin()->second); |
| 108 return filtered; |
| 109 } |
| 110 |
71 } // namespace cricket | 111 } // namespace cricket |
OLD | NEW |