Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: webrtc/api/rtpreceiver.h

Issue 2046173002: Use VoiceChannel/VideoChannel directly from RtpSender/RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 cricket::VoiceChannel/cricket::VideoChannel)
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/mediastreaminterface.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 #include "webrtc/pc/channel.h"
26 27
27 namespace webrtc { 28 namespace webrtc {
28 29
29 // Internal class used by PeerConnection. 30 // Internal class used by PeerConnection.
30 class RtpReceiverInternal : public RtpReceiverInterface { 31 class RtpReceiverInternal : public RtpReceiverInterface {
31 public: 32 public:
32 virtual void Stop() = 0; 33 virtual void Stop() = 0;
33 }; 34 };
34 35
35 class AudioRtpReceiver : public ObserverInterface, 36 class AudioRtpReceiver : public ObserverInterface,
36 public AudioSourceInterface::AudioObserver, 37 public AudioSourceInterface::AudioObserver,
37 public rtc::RefCountedObject<RtpReceiverInternal> { 38 public rtc::RefCountedObject<RtpReceiverInternal> {
38 public: 39 public:
39 AudioRtpReceiver(MediaStreamInterface* stream, 40 AudioRtpReceiver(MediaStreamInterface* stream,
40 const std::string& track_id, 41 const std::string& track_id,
41 uint32_t ssrc, 42 uint32_t ssrc,
42 AudioProviderInterface* provider); 43 cricket::VoiceChannel* channel);
43 44
44 virtual ~AudioRtpReceiver(); 45 virtual ~AudioRtpReceiver();
45 46
46 // ObserverInterface implementation 47 // ObserverInterface implementation
47 void OnChanged() override; 48 void OnChanged() override;
48 49
49 // AudioSourceInterface::AudioObserver implementation 50 // AudioSourceInterface::AudioObserver implementation
50 void OnSetVolume(double volume) override; 51 void OnSetVolume(double volume) override;
51 52
52 rtc::scoped_refptr<AudioTrackInterface> audio_track() const { 53 rtc::scoped_refptr<AudioTrackInterface> audio_track() const {
53 return track_.get(); 54 return track_.get();
54 } 55 }
55 56
56 // RtpReceiverInterface implementation 57 // RtpReceiverInterface implementation
57 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 58 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
58 return track_.get(); 59 return track_.get();
59 } 60 }
60 61
62 cricket::MediaType media_type() const override {
63 return cricket::MEDIA_TYPE_AUDIO;
64 }
65
61 std::string id() const override { return id_; } 66 std::string id() const override { return id_; }
62 67
63 RtpParameters GetParameters() const override; 68 RtpParameters GetParameters() const override;
64 bool SetParameters(const RtpParameters& parameters) override; 69 bool SetParameters(const RtpParameters& parameters) override;
65 70
66 // RtpReceiverInternal implementation. 71 // RtpReceiverInternal implementation.
67 void Stop() override; 72 void Stop() override;
68 73
74 // Does not take ownership.
75 // Should call SetChannel(nullptr) before |channel| is destroyed.
76 void SetChannel(cricket::VoiceChannel* channel) { channel_ = channel; }
77
69 private: 78 private:
70 void Reconfigure(); 79 void Reconfigure();
71 80
72 const std::string id_; 81 const std::string id_;
73 const uint32_t ssrc_; 82 const uint32_t ssrc_;
74 AudioProviderInterface* provider_; // Set to null in Stop(). 83 cricket::VoiceChannel* channel_;
75 const rtc::scoped_refptr<AudioTrackInterface> track_; 84 const rtc::scoped_refptr<AudioTrackInterface> track_;
76 bool cached_track_enabled_; 85 bool cached_track_enabled_;
86 double cached_volume_ = 1;
87 bool stopped_ = false;
77 }; 88 };
78 89
79 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> { 90 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> {
80 public: 91 public:
81 VideoRtpReceiver(MediaStreamInterface* stream, 92 VideoRtpReceiver(MediaStreamInterface* stream,
82 const std::string& track_id, 93 const std::string& track_id,
83 rtc::Thread* worker_thread, 94 rtc::Thread* worker_thread,
84 uint32_t ssrc, 95 uint32_t ssrc,
85 VideoProviderInterface* provider); 96 cricket::VideoChannel* channel);
86 97
87 virtual ~VideoRtpReceiver(); 98 virtual ~VideoRtpReceiver();
88 99
89 rtc::scoped_refptr<VideoTrackInterface> video_track() const { 100 rtc::scoped_refptr<VideoTrackInterface> video_track() const {
90 return track_.get(); 101 return track_.get();
91 } 102 }
92 103
93 // RtpReceiverInterface implementation 104 // RtpReceiverInterface implementation
94 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 105 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
95 return track_.get(); 106 return track_.get();
96 } 107 }
97 108
109 cricket::MediaType media_type() const override {
110 return cricket::MEDIA_TYPE_VIDEO;
111 }
112
98 std::string id() const override { return id_; } 113 std::string id() const override { return id_; }
99 114
100 RtpParameters GetParameters() const override; 115 RtpParameters GetParameters() const override;
101 bool SetParameters(const RtpParameters& parameters) override; 116 bool SetParameters(const RtpParameters& parameters) override;
102 117
103 // RtpReceiverInternal implementation. 118 // RtpReceiverInternal implementation.
104 void Stop() override; 119 void Stop() override;
105 120
121 // Does not take ownership.
122 // Should call SetChannel(nullptr) before |channel| is destroyed.
123 void SetChannel(cricket::VideoChannel* channel) { channel_ = channel; }
124
106 private: 125 private:
107 std::string id_; 126 std::string id_;
108 uint32_t ssrc_; 127 uint32_t ssrc_;
109 VideoProviderInterface* provider_; 128 cricket::VideoChannel* channel_;
110 // |broadcaster_| is needed since the decoder can only handle one sink. 129 // |broadcaster_| is needed since the decoder can only handle one sink.
111 // It might be better if the decoder can handle multiple sinks and consider 130 // It might be better if the decoder can handle multiple sinks and consider
112 // the VideoSinkWants. 131 // the VideoSinkWants.
113 rtc::VideoBroadcaster broadcaster_; 132 rtc::VideoBroadcaster broadcaster_;
114 // |source_| is held here to be able to change the state of the source when 133 // |source_| is held here to be able to change the state of the source when
115 // the VideoRtpReceiver is stopped. 134 // the VideoRtpReceiver is stopped.
116 rtc::scoped_refptr<VideoTrackSource> source_; 135 rtc::scoped_refptr<VideoTrackSource> source_;
117 rtc::scoped_refptr<VideoTrackInterface> track_; 136 rtc::scoped_refptr<VideoTrackInterface> track_;
137 bool stopped_ = false;
118 }; 138 };
119 139
120 } // namespace webrtc 140 } // namespace webrtc
121 141
122 #endif // WEBRTC_API_RTPRECEIVER_H_ 142 #endif // WEBRTC_API_RTPRECEIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698