You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2015 The WebRTC project authors. All Rights Reserved.
  3. *
  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
  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. #include "pc/rtp_receiver.h"
  11. #include <stddef.h>
  12. #include <utility>
  13. #include <vector>
  14. #include "api/media_stream_proxy.h"
  15. #include "api/media_stream_track_proxy.h"
  16. #include "pc/media_stream.h"
  17. #include "rtc_base/checks.h"
  18. #include "rtc_base/location.h"
  19. #include "rtc_base/logging.h"
  20. #include "rtc_base/trace_event.h"
  21. namespace webrtc {
  22. // This function is only expected to be called on the signalling thread.
  23. int RtpReceiverInternal::GenerateUniqueId() {
  24. static int g_unique_id = 0;
  25. return ++g_unique_id;
  26. }
  27. std::vector<rtc::scoped_refptr<MediaStreamInterface>>
  28. RtpReceiverInternal::CreateStreamsFromIds(std::vector<std::string> stream_ids) {
  29. std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams(
  30. stream_ids.size());
  31. for (size_t i = 0; i < stream_ids.size(); ++i) {
  32. streams[i] = MediaStreamProxy::Create(
  33. rtc::Thread::Current(), MediaStream::Create(std::move(stream_ids[i])));
  34. }
  35. return streams;
  36. }
  37. // Attempt to attach the frame decryptor to the current media channel on the
  38. // correct worker thread only if both the media channel exists and a ssrc has
  39. // been allocated to the stream.
  40. void RtpReceiverInternal::MaybeAttachFrameDecryptorToMediaChannel(
  41. const absl::optional<uint32_t>& ssrc,
  42. rtc::Thread* worker_thread,
  43. rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor,
  44. cricket::MediaChannel* media_channel,
  45. bool stopped) {
  46. if (media_channel && frame_decryptor && ssrc.has_value() && !stopped) {
  47. worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
  48. media_channel->SetFrameDecryptor(*ssrc, frame_decryptor);
  49. });
  50. }
  51. }
  52. } // namespace webrtc