2015-09-24 16:47:53 -07:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
2015-09-24 16:47:53 -07:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2015-09-24 16:47:53 -07:00
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/rtp_receiver.h"
|
2015-09-24 16:47:53 -07:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stddef.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2017-11-21 13:41:51 +01:00
|
|
|
#include <utility>
|
2017-10-30 09:57:42 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/media_stream_proxy.h"
|
|
|
|
|
#include "api/media_stream_track_proxy.h"
|
|
|
|
|
#include "pc/media_stream.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/location.h"
|
|
|
|
|
#include "rtc_base/logging.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/trace_event.h"
|
2015-09-28 16:53:55 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2018-01-11 17:18:19 +01:00
|
|
|
// This function is only expected to be called on the signalling thread.
|
2019-02-11 10:29:19 +01:00
|
|
|
int RtpReceiverInternal::GenerateUniqueId() {
|
2018-01-11 17:18:19 +01:00
|
|
|
static int g_unique_id = 0;
|
|
|
|
|
|
|
|
|
|
return ++g_unique_id;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 10:29:19 +01:00
|
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>>
|
|
|
|
|
RtpReceiverInternal::CreateStreamsFromIds(std::vector<std::string> stream_ids) {
|
2018-07-04 20:51:53 +02:00
|
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams(
|
|
|
|
|
stream_ids.size());
|
|
|
|
|
for (size_t i = 0; i < stream_ids.size(); ++i) {
|
|
|
|
|
streams[i] = MediaStreamProxy::Create(
|
|
|
|
|
rtc::Thread::Current(), MediaStream::Create(std::move(stream_ids[i])));
|
|
|
|
|
}
|
|
|
|
|
return streams;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-04 14:22:34 -07:00
|
|
|
// Attempt to attach the frame decryptor to the current media channel on the
|
|
|
|
|
// correct worker thread only if both the media channel exists and a ssrc has
|
|
|
|
|
// been allocated to the stream.
|
2019-02-11 10:29:19 +01:00
|
|
|
void RtpReceiverInternal::MaybeAttachFrameDecryptorToMediaChannel(
|
2018-10-04 14:22:34 -07:00
|
|
|
const absl::optional<uint32_t>& ssrc,
|
2018-09-10 14:06:02 -07:00
|
|
|
rtc::Thread* worker_thread,
|
2018-10-04 14:22:34 -07:00
|
|
|
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor,
|
2018-10-26 13:16:16 -07:00
|
|
|
cricket::MediaChannel* media_channel,
|
|
|
|
|
bool stopped) {
|
|
|
|
|
if (media_channel && frame_decryptor && ssrc.has_value() && !stopped) {
|
2018-10-09 17:29:54 -07:00
|
|
|
worker_thread->Invoke<void>(RTC_FROM_HERE, [&] {
|
2018-10-04 14:22:34 -07:00
|
|
|
media_channel->SetFrameDecryptor(*ssrc, frame_decryptor);
|
2018-09-10 14:06:02 -07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
} // namespace webrtc
|