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
|
|
|
*/
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// This file contains classes that implement RtpReceiverInterface.
|
|
|
|
|
// An RtpReceiver associates a MediaStreamTrackInterface with an underlying
|
2016-06-27 16:30:35 -07:00
|
|
|
// transport (provided by cricket::VoiceChannel/cricket::VideoChannel)
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#ifndef WEBRTC_API_RTPRECEIVER_H_
|
|
|
|
|
#define WEBRTC_API_RTPRECEIVER_H_
|
2015-09-28 16:53:55 -07:00
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2016-06-27 16:30:35 -07:00
|
|
|
#include "webrtc/api/mediastreaminterface.h"
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/rtpreceiverinterface.h"
|
2016-03-24 03:16:19 -07:00
|
|
|
#include "webrtc/api/remoteaudiosource.h"
|
2016-03-10 18:32:00 +01:00
|
|
|
#include "webrtc/api/videotracksource.h"
|
2015-09-28 16:53:55 -07:00
|
|
|
#include "webrtc/base/basictypes.h"
|
2016-06-14 11:47:14 -07:00
|
|
|
#include "webrtc/base/sigslot.h"
|
2016-03-10 18:32:00 +01:00
|
|
|
#include "webrtc/media/base/videobroadcaster.h"
|
2016-06-27 16:30:35 -07:00
|
|
|
#include "webrtc/pc/channel.h"
|
2015-09-28 16:53:55 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
// Internal class used by PeerConnection.
|
|
|
|
|
class RtpReceiverInternal : public RtpReceiverInterface {
|
|
|
|
|
public:
|
|
|
|
|
virtual void Stop() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
class AudioRtpReceiver : public ObserverInterface,
|
|
|
|
|
public AudioSourceInterface::AudioObserver,
|
2016-06-14 11:47:14 -07:00
|
|
|
public rtc::RefCountedObject<RtpReceiverInternal>,
|
|
|
|
|
public sigslot::has_slots<> {
|
2015-09-28 16:53:55 -07:00
|
|
|
public:
|
2016-03-24 03:16:19 -07:00
|
|
|
AudioRtpReceiver(MediaStreamInterface* stream,
|
|
|
|
|
const std::string& track_id,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc,
|
2016-06-27 16:30:35 -07:00
|
|
|
cricket::VoiceChannel* channel);
|
2015-09-28 16:53:55 -07:00
|
|
|
|
|
|
|
|
virtual ~AudioRtpReceiver();
|
|
|
|
|
|
|
|
|
|
// ObserverInterface implementation
|
|
|
|
|
void OnChanged() override;
|
|
|
|
|
|
|
|
|
|
// AudioSourceInterface::AudioObserver implementation
|
|
|
|
|
void OnSetVolume(double volume) override;
|
|
|
|
|
|
2016-03-24 03:16:19 -07:00
|
|
|
rtc::scoped_refptr<AudioTrackInterface> audio_track() const {
|
|
|
|
|
return track_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// RtpReceiverInterface implementation
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
|
|
|
|
|
return track_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 16:30:35 -07:00
|
|
|
cricket::MediaType media_type() const override {
|
|
|
|
|
return cricket::MEDIA_TYPE_AUDIO;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
std::string id() const override { return id_; }
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
RtpParameters GetParameters() const override;
|
|
|
|
|
bool SetParameters(const RtpParameters& parameters) override;
|
|
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
// RtpReceiverInternal implementation.
|
|
|
|
|
void Stop() override;
|
|
|
|
|
|
2016-06-14 11:47:14 -07:00
|
|
|
void SetObserver(RtpReceiverObserverInterface* observer) override;
|
|
|
|
|
|
2016-06-27 16:30:35 -07:00
|
|
|
// Does not take ownership.
|
|
|
|
|
// Should call SetChannel(nullptr) before |channel| is destroyed.
|
|
|
|
|
void SetChannel(cricket::VoiceChannel* channel);
|
2016-06-14 11:47:14 -07:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
private:
|
|
|
|
|
void Reconfigure();
|
2016-06-27 16:30:35 -07:00
|
|
|
void OnFirstPacketReceived(cricket::BaseChannel* channel);
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2015-12-12 01:37:01 +01:00
|
|
|
const std::string id_;
|
|
|
|
|
const uint32_t ssrc_;
|
2016-06-27 16:30:35 -07:00
|
|
|
cricket::VoiceChannel* channel_;
|
2016-03-24 03:16:19 -07:00
|
|
|
const rtc::scoped_refptr<AudioTrackInterface> track_;
|
2015-09-28 16:53:55 -07:00
|
|
|
bool cached_track_enabled_;
|
2016-06-27 16:30:35 -07:00
|
|
|
double cached_volume_ = 1;
|
|
|
|
|
bool stopped_ = false;
|
2016-06-14 11:47:14 -07:00
|
|
|
RtpReceiverObserverInterface* observer_ = nullptr;
|
|
|
|
|
bool received_first_packet_ = false;
|
2015-09-28 16:53:55 -07:00
|
|
|
};
|
|
|
|
|
|
2016-06-14 11:47:14 -07:00
|
|
|
class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal>,
|
|
|
|
|
public sigslot::has_slots<> {
|
2015-09-28 16:53:55 -07:00
|
|
|
public:
|
2016-03-10 18:32:00 +01:00
|
|
|
VideoRtpReceiver(MediaStreamInterface* stream,
|
|
|
|
|
const std::string& track_id,
|
|
|
|
|
rtc::Thread* worker_thread,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc,
|
2016-06-27 16:30:35 -07:00
|
|
|
cricket::VideoChannel* channel);
|
2015-09-28 16:53:55 -07:00
|
|
|
|
|
|
|
|
virtual ~VideoRtpReceiver();
|
|
|
|
|
|
2016-03-10 18:32:00 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackInterface> video_track() const {
|
|
|
|
|
return track_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// RtpReceiverInterface implementation
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
|
|
|
|
|
return track_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 16:30:35 -07:00
|
|
|
cricket::MediaType media_type() const override {
|
|
|
|
|
return cricket::MEDIA_TYPE_VIDEO;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
std::string id() const override { return id_; }
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
RtpParameters GetParameters() const override;
|
|
|
|
|
bool SetParameters(const RtpParameters& parameters) override;
|
|
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
// RtpReceiverInternal implementation.
|
|
|
|
|
void Stop() override;
|
|
|
|
|
|
2016-06-14 11:47:14 -07:00
|
|
|
void SetObserver(RtpReceiverObserverInterface* observer) override;
|
|
|
|
|
|
2016-06-27 16:30:35 -07:00
|
|
|
// Does not take ownership.
|
|
|
|
|
// Should call SetChannel(nullptr) before |channel| is destroyed.
|
|
|
|
|
void SetChannel(cricket::VideoChannel* channel);
|
2016-06-14 11:47:14 -07:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
private:
|
2016-06-27 16:30:35 -07:00
|
|
|
void OnFirstPacketReceived(cricket::BaseChannel* channel);
|
2016-06-14 11:47:14 -07:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
std::string id_;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc_;
|
2016-06-27 16:30:35 -07:00
|
|
|
cricket::VideoChannel* channel_;
|
2016-03-10 18:32:00 +01:00
|
|
|
// |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_;
|
2016-06-27 16:30:35 -07:00
|
|
|
bool stopped_ = false;
|
2016-06-14 11:47:14 -07:00
|
|
|
RtpReceiverObserverInterface* observer_ = nullptr;
|
|
|
|
|
bool received_first_packet_ = false;
|
2015-09-28 16:53:55 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#endif // WEBRTC_API_RTPRECEIVER_H_
|