
This reverts commit 8b13f96e2d4b0449e54a3665121a4302ceb56e80. Original change's description: > Revert "Add AddTransceiver and GetTransceivers to PeerConnection" > > This reverts commit f93d2800d9b0d5818a5a383def0aaef3d441df3a. > > Reason for revert: https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.webrtc.fyi%2Fios-device%2F5804%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout > > Original change's description: > > Add AddTransceiver and GetTransceivers to PeerConnection > > > > WebRTC 1.0 has added the transceiver API to PeerConnection. This > > is the first step towards exposing this to WebRTC consumers. For > > now, transceivers can be added and fetched but there is not yet > > support for creating offers/answers or setting local/remote > > descriptions. That support ("Unified Plan") will be added in > > follow-up CLs. > > > > The transceiver API is currently only available if the application > > opts in by specifying the kUnifiedPlan SDP semantics when creating > > the PeerConnection. > > > > Bug: webrtc:7600 > > Change-Id: I0b8ee24b489b45bb4c5f60b699bd20c61af01d8e > > Reviewed-on: https://webrtc-review.googlesource.com/23880 > > Commit-Queue: Steve Anton <steveanton@webrtc.org> > > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20896} > > TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org > > Change-Id: Ie91ea4988dba25c20e2532114d3a9d859a932d4c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:7600 > Reviewed-on: https://webrtc-review.googlesource.com/26400 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20897} TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org Change-Id: I19fdf08c54f09302794e998a0ffddb82ae0d7b41 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7600 Reviewed-on: https://webrtc-review.googlesource.com/26401 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20898}
184 lines
5.8 KiB
C++
184 lines
5.8 KiB
C++
/*
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
// This file contains classes that implement RtpReceiverInterface.
|
|
// An RtpReceiver associates a MediaStreamTrackInterface with an underlying
|
|
// transport (provided by cricket::VoiceChannel/cricket::VideoChannel)
|
|
|
|
#ifndef PC_RTPRECEIVER_H_
|
|
#define PC_RTPRECEIVER_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "api/mediastreaminterface.h"
|
|
#include "api/rtpreceiverinterface.h"
|
|
#include "media/base/videobroadcaster.h"
|
|
#include "pc/channel.h"
|
|
#include "pc/remoteaudiosource.h"
|
|
#include "pc/videotracksource.h"
|
|
#include "rtc_base/basictypes.h"
|
|
#include "rtc_base/sigslot.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// Internal class used by PeerConnection.
|
|
class RtpReceiverInternal : public RtpReceiverInterface {
|
|
public:
|
|
virtual void Stop() = 0;
|
|
// This SSRC is used as an identifier for the receiver between the API layer
|
|
// and the WebRtcVideoEngine, WebRtcVoiceEngine layer.
|
|
virtual uint32_t ssrc() const = 0;
|
|
};
|
|
|
|
class AudioRtpReceiver : public ObserverInterface,
|
|
public AudioSourceInterface::AudioObserver,
|
|
public rtc::RefCountedObject<RtpReceiverInternal>,
|
|
public sigslot::has_slots<> {
|
|
public:
|
|
// An SSRC of 0 will create a receiver that will match the first SSRC it
|
|
// sees.
|
|
// TODO(deadbeef): Use rtc::Optional, or have another constructor that
|
|
// doesn't take an SSRC, and make this one DCHECK(ssrc != 0).
|
|
AudioRtpReceiver(
|
|
const std::string& receiver_id,
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams,
|
|
uint32_t ssrc,
|
|
cricket::VoiceChannel* channel);
|
|
virtual ~AudioRtpReceiver();
|
|
|
|
// ObserverInterface implementation
|
|
void OnChanged() override;
|
|
|
|
// AudioSourceInterface::AudioObserver implementation
|
|
void OnSetVolume(double volume) override;
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> audio_track() const {
|
|
return track_.get();
|
|
}
|
|
|
|
// RtpReceiverInterface implementation
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
|
|
return track_.get();
|
|
}
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams()
|
|
const override {
|
|
return streams_;
|
|
}
|
|
|
|
cricket::MediaType media_type() const override {
|
|
return cricket::MEDIA_TYPE_AUDIO;
|
|
}
|
|
|
|
std::string id() const override { return id_; }
|
|
|
|
RtpParameters GetParameters() const override;
|
|
bool SetParameters(const RtpParameters& parameters) override;
|
|
|
|
// RtpReceiverInternal implementation.
|
|
void Stop() override;
|
|
uint32_t ssrc() const override { return ssrc_; }
|
|
|
|
void SetObserver(RtpReceiverObserverInterface* observer) override;
|
|
|
|
// Does not take ownership.
|
|
// Should call SetChannel(nullptr) before |channel| is destroyed.
|
|
void SetChannel(cricket::VoiceChannel* channel);
|
|
|
|
std::vector<RtpSource> GetSources() const override;
|
|
|
|
private:
|
|
void Reconfigure();
|
|
void OnFirstPacketReceived(cricket::BaseChannel* channel);
|
|
|
|
const std::string id_;
|
|
const uint32_t ssrc_;
|
|
cricket::VoiceChannel* channel_;
|
|
const rtc::scoped_refptr<AudioTrackInterface> track_;
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams_;
|
|
bool cached_track_enabled_;
|
|
double cached_volume_ = 1;
|
|
bool stopped_ = false;
|
|
RtpReceiverObserverInterface* observer_ = nullptr;
|
|
bool received_first_packet_ = false;
|
|
};
|
|
|
|
class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal>,
|
|
public sigslot::has_slots<> {
|
|
public:
|
|
// An SSRC of 0 will create a receiver that will match the first SSRC it
|
|
// sees.
|
|
VideoRtpReceiver(
|
|
const std::string& track_id,
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams,
|
|
rtc::Thread* worker_thread,
|
|
uint32_t ssrc,
|
|
cricket::VideoChannel* channel);
|
|
|
|
virtual ~VideoRtpReceiver();
|
|
|
|
rtc::scoped_refptr<VideoTrackInterface> video_track() const {
|
|
return track_.get();
|
|
}
|
|
|
|
// RtpReceiverInterface implementation
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
|
|
return track_.get();
|
|
}
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams()
|
|
const override {
|
|
return streams_;
|
|
}
|
|
|
|
cricket::MediaType media_type() const override {
|
|
return cricket::MEDIA_TYPE_VIDEO;
|
|
}
|
|
|
|
std::string id() const override { return id_; }
|
|
|
|
RtpParameters GetParameters() const override;
|
|
bool SetParameters(const RtpParameters& parameters) override;
|
|
|
|
// RtpReceiverInternal implementation.
|
|
void Stop() override;
|
|
uint32_t ssrc() const override { return ssrc_; }
|
|
|
|
void SetObserver(RtpReceiverObserverInterface* observer) override;
|
|
|
|
// Does not take ownership.
|
|
// Should call SetChannel(nullptr) before |channel| is destroyed.
|
|
void SetChannel(cricket::VideoChannel* channel);
|
|
|
|
private:
|
|
void OnFirstPacketReceived(cricket::BaseChannel* channel);
|
|
|
|
std::string id_;
|
|
uint32_t ssrc_;
|
|
cricket::VideoChannel* channel_;
|
|
// |broadcaster_| is needed since the decoder can only handle one sink.
|
|
// It might be better if the decoder can handle multiple sinks and consider
|
|
// the VideoSinkWants.
|
|
rtc::VideoBroadcaster broadcaster_;
|
|
// |source_| is held here to be able to change the state of the source when
|
|
// the VideoRtpReceiver is stopped.
|
|
rtc::scoped_refptr<VideoTrackSource> source_;
|
|
rtc::scoped_refptr<VideoTrackInterface> track_;
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams_;
|
|
bool stopped_ = false;
|
|
RtpReceiverObserverInterface* observer_ = nullptr;
|
|
bool received_first_packet_ = false;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // PC_RTPRECEIVER_H_
|