OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // This file contains classes that implement RtpReceiverInterface. | 11 // This file contains classes that implement RtpReceiverInterface. |
12 // An RtpReceiver associates a MediaStreamTrackInterface with an underlying | 12 // An RtpReceiver associates a MediaStreamTrackInterface with an underlying |
13 // transport (provided by AudioProviderInterface/VideoProviderInterface) | 13 // transport (provided by AudioProviderInterface/VideoProviderInterface) |
14 | 14 |
15 #ifndef WEBRTC_API_RTPRECEIVER_H_ | 15 #ifndef WEBRTC_API_RTPRECEIVER_H_ |
16 #define WEBRTC_API_RTPRECEIVER_H_ | 16 #define WEBRTC_API_RTPRECEIVER_H_ |
17 | 17 |
18 #include <string> | 18 #include <string> |
19 | 19 |
20 #include "webrtc/api/mediastreamprovider.h" | 20 #include "webrtc/api/mediastreamprovider.h" |
21 #include "webrtc/api/rtpreceiverinterface.h" | 21 #include "webrtc/api/rtpreceiverinterface.h" |
22 #include "webrtc/api/remoteaudiosource.h" | 22 #include "webrtc/api/remoteaudiosource.h" |
23 #include "webrtc/api/videotracksource.h" | 23 #include "webrtc/api/videotracksource.h" |
24 #include "webrtc/base/basictypes.h" | 24 #include "webrtc/base/basictypes.h" |
25 #include "webrtc/media/base/videobroadcaster.h" | 25 #include "webrtc/media/base/videobroadcaster.h" |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
28 | 28 |
| 29 // Internal class used by PeerConnection. |
| 30 class RtpReceiverInternal : public RtpReceiverInterface { |
| 31 public: |
| 32 virtual void Stop() = 0; |
| 33 }; |
| 34 |
29 class AudioRtpReceiver : public ObserverInterface, | 35 class AudioRtpReceiver : public ObserverInterface, |
30 public AudioSourceInterface::AudioObserver, | 36 public AudioSourceInterface::AudioObserver, |
31 public rtc::RefCountedObject<RtpReceiverInterface> { | 37 public rtc::RefCountedObject<RtpReceiverInternal> { |
32 public: | 38 public: |
33 AudioRtpReceiver(MediaStreamInterface* stream, | 39 AudioRtpReceiver(MediaStreamInterface* stream, |
34 const std::string& track_id, | 40 const std::string& track_id, |
35 uint32_t ssrc, | 41 uint32_t ssrc, |
36 AudioProviderInterface* provider); | 42 AudioProviderInterface* provider); |
37 | 43 |
38 virtual ~AudioRtpReceiver(); | 44 virtual ~AudioRtpReceiver(); |
39 | 45 |
40 // ObserverInterface implementation | 46 // ObserverInterface implementation |
41 void OnChanged() override; | 47 void OnChanged() override; |
42 | 48 |
43 // AudioSourceInterface::AudioObserver implementation | 49 // AudioSourceInterface::AudioObserver implementation |
44 void OnSetVolume(double volume) override; | 50 void OnSetVolume(double volume) override; |
45 | 51 |
46 rtc::scoped_refptr<AudioTrackInterface> audio_track() const { | 52 rtc::scoped_refptr<AudioTrackInterface> audio_track() const { |
47 return track_.get(); | 53 return track_.get(); |
48 } | 54 } |
49 | 55 |
50 // RtpReceiverInterface implementation | 56 // RtpReceiverInterface implementation |
51 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { | 57 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { |
52 return track_.get(); | 58 return track_.get(); |
53 } | 59 } |
54 | 60 |
55 std::string id() const override { return id_; } | 61 std::string id() const override { return id_; } |
56 | 62 |
57 void Stop() override; | |
58 | |
59 RtpParameters GetParameters() const override; | 63 RtpParameters GetParameters() const override; |
60 bool SetParameters(const RtpParameters& parameters) override; | 64 bool SetParameters(const RtpParameters& parameters) override; |
61 | 65 |
| 66 // RtpReceiverInternal implementation. |
| 67 void Stop() override; |
| 68 |
62 private: | 69 private: |
63 void Reconfigure(); | 70 void Reconfigure(); |
64 | 71 |
65 const std::string id_; | 72 const std::string id_; |
66 const uint32_t ssrc_; | 73 const uint32_t ssrc_; |
67 AudioProviderInterface* provider_; // Set to null in Stop(). | 74 AudioProviderInterface* provider_; // Set to null in Stop(). |
68 const rtc::scoped_refptr<AudioTrackInterface> track_; | 75 const rtc::scoped_refptr<AudioTrackInterface> track_; |
69 bool cached_track_enabled_; | 76 bool cached_track_enabled_; |
70 }; | 77 }; |
71 | 78 |
72 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> { | 79 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> { |
73 public: | 80 public: |
74 VideoRtpReceiver(MediaStreamInterface* stream, | 81 VideoRtpReceiver(MediaStreamInterface* stream, |
75 const std::string& track_id, | 82 const std::string& track_id, |
76 rtc::Thread* worker_thread, | 83 rtc::Thread* worker_thread, |
77 uint32_t ssrc, | 84 uint32_t ssrc, |
78 VideoProviderInterface* provider); | 85 VideoProviderInterface* provider); |
79 | 86 |
80 virtual ~VideoRtpReceiver(); | 87 virtual ~VideoRtpReceiver(); |
81 | 88 |
82 rtc::scoped_refptr<VideoTrackInterface> video_track() const { | 89 rtc::scoped_refptr<VideoTrackInterface> video_track() const { |
83 return track_.get(); | 90 return track_.get(); |
84 } | 91 } |
85 | 92 |
86 // RtpReceiverInterface implementation | 93 // RtpReceiverInterface implementation |
87 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { | 94 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { |
88 return track_.get(); | 95 return track_.get(); |
89 } | 96 } |
90 | 97 |
91 std::string id() const override { return id_; } | 98 std::string id() const override { return id_; } |
92 | 99 |
93 void Stop() override; | |
94 | |
95 RtpParameters GetParameters() const override; | 100 RtpParameters GetParameters() const override; |
96 bool SetParameters(const RtpParameters& parameters) override; | 101 bool SetParameters(const RtpParameters& parameters) override; |
97 | 102 |
| 103 // RtpReceiverInternal implementation. |
| 104 void Stop() override; |
| 105 |
98 private: | 106 private: |
99 std::string id_; | 107 std::string id_; |
100 uint32_t ssrc_; | 108 uint32_t ssrc_; |
101 VideoProviderInterface* provider_; | 109 VideoProviderInterface* provider_; |
102 // |broadcaster_| is needed since the decoder can only handle one sink. | 110 // |broadcaster_| is needed since the decoder can only handle one sink. |
103 // It might be better if the decoder can handle multiple sinks and consider | 111 // It might be better if the decoder can handle multiple sinks and consider |
104 // the VideoSinkWants. | 112 // the VideoSinkWants. |
105 rtc::VideoBroadcaster broadcaster_; | 113 rtc::VideoBroadcaster broadcaster_; |
106 // |source_| is held here to be able to change the state of the source when | 114 // |source_| is held here to be able to change the state of the source when |
107 // the VideoRtpReceiver is stopped. | 115 // the VideoRtpReceiver is stopped. |
108 rtc::scoped_refptr<VideoTrackSource> source_; | 116 rtc::scoped_refptr<VideoTrackSource> source_; |
109 rtc::scoped_refptr<VideoTrackInterface> track_; | 117 rtc::scoped_refptr<VideoTrackInterface> track_; |
110 }; | 118 }; |
111 | 119 |
112 } // namespace webrtc | 120 } // namespace webrtc |
113 | 121 |
114 #endif // WEBRTC_API_RTPRECEIVER_H_ | 122 #endif // WEBRTC_API_RTPRECEIVER_H_ |
OLD | NEW |