| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "pc/rtp_receiver.h" |
| 12 |
| 13 | #include <stddef.h> |
| 14 |
| 15 | #include <utility> |
| 16 | #include <vector> |
| 17 |
| 18 | #include "api/media_stream_proxy.h" |
| 19 | #include "api/media_stream_track_proxy.h" |
| 20 | #include "pc/media_stream.h" |
| 21 | #include "rtc_base/checks.h" |
| 22 | #include "rtc_base/location.h" |
| 23 | #include "rtc_base/logging.h" |
| 24 | #include "rtc_base/trace_event.h" |
| 25 |
| 26 | namespace webrtc { |
| 27 |
| 28 | // This function is only expected to be called on the signalling thread. |
| 29 | int RtpReceiverInternal::GenerateUniqueId() { |
| 30 | static int g_unique_id = 0; |
| 31 |
| 32 | return ++g_unique_id; |
| 33 | } |
| 34 |
| 35 | std::vector<rtc::scoped_refptr<MediaStreamInterface>> |
| 36 | RtpReceiverInternal::CreateStreamsFromIds(std::vector<std::string> stream_ids) { |
| 37 | std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams( |
| 38 | stream_ids.size()); |
| 39 | for (size_t i = 0; i < stream_ids.size(); ++i) { |
| 40 | streams[i] = MediaStreamProxy::Create( |
| 41 | rtc::Thread::Current(), MediaStream::Create(std::move(stream_ids[i]))); |
| 42 | } |
| 43 | return streams; |
| 44 | } |
| 45 |
| 46 | // Attempt to attach the frame decryptor to the current media channel on the |
| 47 | // correct worker thread only if both the media channel exists and a ssrc has |
| 48 | // been allocated to the stream. |
| 49 | void RtpReceiverInternal::MaybeAttachFrameDecryptorToMediaChannel( |
| 50 | const absl::optional<uint32_t>& ssrc, |
| 51 | rtc::Thread* worker_thread, |
| 52 | rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor, |
| 53 | cricket::MediaChannel* media_channel, |
| 54 | bool stopped) { |
| 55 | if (media_channel && frame_decryptor && ssrc.has_value() && !stopped) { |
| 56 | worker_thread->Invoke<void>(RTC_FROM_HERE, [&] { |
| 57 | media_channel->SetFrameDecryptor(*ssrc, frame_decryptor); |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 |
| 62 | } // namespace webrtc |
| 63 |