blob: 43adc7294601d0930dcd7c5ad80637056fee7edc [file] [log] [blame]
deadbeef6979b022015-09-24 16:47:53 -07001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
deadbeef6979b022015-09-24 16:47:53 -07003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.
deadbeef6979b022015-09-24 16:47:53 -07009 */
10
deadbeef70ab1a12015-09-28 16:53:55 -070011// This file contains classes that implement RtpReceiverInterface.
12// An RtpReceiver associates a MediaStreamTrackInterface with an underlying
13// transport (provided by AudioProviderInterface/VideoProviderInterface)
14
Henrik Kjellander15583c12016-02-10 10:53:12 +010015#ifndef WEBRTC_API_RTPRECEIVER_H_
16#define WEBRTC_API_RTPRECEIVER_H_
deadbeef70ab1a12015-09-28 16:53:55 -070017
18#include <string>
19
Henrik Kjellander15583c12016-02-10 10:53:12 +010020#include "webrtc/api/mediastreamprovider.h"
21#include "webrtc/api/rtpreceiverinterface.h"
deadbeef70ab1a12015-09-28 16:53:55 -070022#include "webrtc/base/basictypes.h"
23
24namespace webrtc {
25
26class AudioRtpReceiver : public ObserverInterface,
27 public AudioSourceInterface::AudioObserver,
28 public rtc::RefCountedObject<RtpReceiverInterface> {
29 public:
30 AudioRtpReceiver(AudioTrackInterface* track,
Peter Boström0c4e06b2015-10-07 12:23:21 +020031 uint32_t ssrc,
deadbeef70ab1a12015-09-28 16:53:55 -070032 AudioProviderInterface* provider);
33
34 virtual ~AudioRtpReceiver();
35
36 // ObserverInterface implementation
37 void OnChanged() override;
38
39 // AudioSourceInterface::AudioObserver implementation
40 void OnSetVolume(double volume) override;
41
42 // RtpReceiverInterface implementation
43 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
44 return track_.get();
45 }
46
47 std::string id() const override { return id_; }
48
49 void Stop() override;
50
51 private:
52 void Reconfigure();
53
Tommif888bb52015-12-12 01:37:01 +010054 const std::string id_;
55 const rtc::scoped_refptr<AudioTrackInterface> track_;
56 const uint32_t ssrc_;
57 AudioProviderInterface* provider_; // Set to null in Stop().
deadbeef70ab1a12015-09-28 16:53:55 -070058 bool cached_track_enabled_;
59};
60
61class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
62 public:
63 VideoRtpReceiver(VideoTrackInterface* track,
Peter Boström0c4e06b2015-10-07 12:23:21 +020064 uint32_t ssrc,
deadbeef70ab1a12015-09-28 16:53:55 -070065 VideoProviderInterface* provider);
66
67 virtual ~VideoRtpReceiver();
68
69 // RtpReceiverInterface implementation
70 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
71 return track_.get();
72 }
73
74 std::string id() const override { return id_; }
75
76 void Stop() override;
77
78 private:
79 std::string id_;
80 rtc::scoped_refptr<VideoTrackInterface> track_;
Peter Boström0c4e06b2015-10-07 12:23:21 +020081 uint32_t ssrc_;
deadbeef70ab1a12015-09-28 16:53:55 -070082 VideoProviderInterface* provider_;
83};
84
85} // namespace webrtc
86
Henrik Kjellander15583c12016-02-10 10:53:12 +010087#endif // WEBRTC_API_RTPRECEIVER_H_