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

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: Moving code that needs to execute out of RTC_DCHECKs. Created 4 years, 5 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
« no previous file with comments | « webrtc/api/remoteaudiosource.cc ('k') | webrtc/api/rtpreceiver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/sigslot.h" 25 #include "webrtc/base/sigslot.h"
26 #include "webrtc/media/base/videobroadcaster.h" 26 #include "webrtc/media/base/videobroadcaster.h"
27 #include "webrtc/pc/channel.h"
27 28
28 namespace webrtc { 29 namespace webrtc {
29 30
30 // Internal class used by PeerConnection. 31 // Internal class used by PeerConnection.
31 class RtpReceiverInternal : public RtpReceiverInterface { 32 class RtpReceiverInternal : public RtpReceiverInterface {
32 public: 33 public:
33 virtual void Stop() = 0; 34 virtual void Stop() = 0;
34 }; 35 };
35 36
36 class AudioRtpReceiver : public ObserverInterface, 37 class AudioRtpReceiver : public ObserverInterface,
37 public AudioSourceInterface::AudioObserver, 38 public AudioSourceInterface::AudioObserver,
38 public rtc::RefCountedObject<RtpReceiverInternal>, 39 public rtc::RefCountedObject<RtpReceiverInternal>,
39 public sigslot::has_slots<> { 40 public sigslot::has_slots<> {
40 public: 41 public:
41 AudioRtpReceiver(MediaStreamInterface* stream, 42 AudioRtpReceiver(MediaStreamInterface* stream,
42 const std::string& track_id, 43 const std::string& track_id,
43 uint32_t ssrc, 44 uint32_t ssrc,
44 AudioProviderInterface* provider); 45 cricket::VoiceChannel* channel);
45 46
46 virtual ~AudioRtpReceiver(); 47 virtual ~AudioRtpReceiver();
47 48
48 // ObserverInterface implementation 49 // ObserverInterface implementation
49 void OnChanged() override; 50 void OnChanged() override;
50 51
51 // AudioSourceInterface::AudioObserver implementation 52 // AudioSourceInterface::AudioObserver implementation
52 void OnSetVolume(double volume) override; 53 void OnSetVolume(double volume) override;
53 54
54 rtc::scoped_refptr<AudioTrackInterface> audio_track() const { 55 rtc::scoped_refptr<AudioTrackInterface> audio_track() const {
55 return track_.get(); 56 return track_.get();
56 } 57 }
57 58
58 // RtpReceiverInterface implementation 59 // RtpReceiverInterface implementation
59 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 60 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
60 return track_.get(); 61 return track_.get();
61 } 62 }
62 63
64 cricket::MediaType media_type() const override {
65 return cricket::MEDIA_TYPE_AUDIO;
66 }
67
63 std::string id() const override { return id_; } 68 std::string id() const override { return id_; }
64 69
65 RtpParameters GetParameters() const override; 70 RtpParameters GetParameters() const override;
66 bool SetParameters(const RtpParameters& parameters) override; 71 bool SetParameters(const RtpParameters& parameters) override;
67 72
68 // RtpReceiverInternal implementation. 73 // RtpReceiverInternal implementation.
69 void Stop() override; 74 void Stop() override;
70 75
71 void SetObserver(RtpReceiverObserverInterface* observer) override; 76 void SetObserver(RtpReceiverObserverInterface* observer) override;
72 77
73 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; } 78 // Does not take ownership.
79 // Should call SetChannel(nullptr) before |channel| is destroyed.
80 void SetChannel(cricket::VoiceChannel* channel);
74 81
75 private: 82 private:
76 void Reconfigure(); 83 void Reconfigure();
77 void OnFirstAudioPacketReceived(); 84 void OnFirstPacketReceived(cricket::BaseChannel* channel);
78 85
79 const std::string id_; 86 const std::string id_;
80 const uint32_t ssrc_; 87 const uint32_t ssrc_;
81 AudioProviderInterface* provider_; // Set to null in Stop(). 88 cricket::VoiceChannel* channel_;
82 const rtc::scoped_refptr<AudioTrackInterface> track_; 89 const rtc::scoped_refptr<AudioTrackInterface> track_;
83 bool cached_track_enabled_; 90 bool cached_track_enabled_;
91 double cached_volume_ = 1;
92 bool stopped_ = false;
84 RtpReceiverObserverInterface* observer_ = nullptr; 93 RtpReceiverObserverInterface* observer_ = nullptr;
85 bool received_first_packet_ = false; 94 bool received_first_packet_ = false;
86 }; 95 };
87 96
88 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal>, 97 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal>,
89 public sigslot::has_slots<> { 98 public sigslot::has_slots<> {
90 public: 99 public:
91 VideoRtpReceiver(MediaStreamInterface* stream, 100 VideoRtpReceiver(MediaStreamInterface* stream,
92 const std::string& track_id, 101 const std::string& track_id,
93 rtc::Thread* worker_thread, 102 rtc::Thread* worker_thread,
94 uint32_t ssrc, 103 uint32_t ssrc,
95 VideoProviderInterface* provider); 104 cricket::VideoChannel* channel);
96 105
97 virtual ~VideoRtpReceiver(); 106 virtual ~VideoRtpReceiver();
98 107
99 rtc::scoped_refptr<VideoTrackInterface> video_track() const { 108 rtc::scoped_refptr<VideoTrackInterface> video_track() const {
100 return track_.get(); 109 return track_.get();
101 } 110 }
102 111
103 // RtpReceiverInterface implementation 112 // RtpReceiverInterface implementation
104 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 113 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
105 return track_.get(); 114 return track_.get();
106 } 115 }
107 116
117 cricket::MediaType media_type() const override {
118 return cricket::MEDIA_TYPE_VIDEO;
119 }
120
108 std::string id() const override { return id_; } 121 std::string id() const override { return id_; }
109 122
110 RtpParameters GetParameters() const override; 123 RtpParameters GetParameters() const override;
111 bool SetParameters(const RtpParameters& parameters) override; 124 bool SetParameters(const RtpParameters& parameters) override;
112 125
113 // RtpReceiverInternal implementation. 126 // RtpReceiverInternal implementation.
114 void Stop() override; 127 void Stop() override;
115 128
116 void SetObserver(RtpReceiverObserverInterface* observer) override; 129 void SetObserver(RtpReceiverObserverInterface* observer) override;
117 130
118 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; } 131 // Does not take ownership.
132 // Should call SetChannel(nullptr) before |channel| is destroyed.
133 void SetChannel(cricket::VideoChannel* channel);
119 134
120 private: 135 private:
121 void OnFirstVideoPacketReceived(); 136 void OnFirstPacketReceived(cricket::BaseChannel* channel);
122 137
123 std::string id_; 138 std::string id_;
124 uint32_t ssrc_; 139 uint32_t ssrc_;
125 VideoProviderInterface* provider_; 140 cricket::VideoChannel* channel_;
126 // |broadcaster_| is needed since the decoder can only handle one sink. 141 // |broadcaster_| is needed since the decoder can only handle one sink.
127 // It might be better if the decoder can handle multiple sinks and consider 142 // It might be better if the decoder can handle multiple sinks and consider
128 // the VideoSinkWants. 143 // the VideoSinkWants.
129 rtc::VideoBroadcaster broadcaster_; 144 rtc::VideoBroadcaster broadcaster_;
130 // |source_| is held here to be able to change the state of the source when 145 // |source_| is held here to be able to change the state of the source when
131 // the VideoRtpReceiver is stopped. 146 // the VideoRtpReceiver is stopped.
132 rtc::scoped_refptr<VideoTrackSource> source_; 147 rtc::scoped_refptr<VideoTrackSource> source_;
133 rtc::scoped_refptr<VideoTrackInterface> track_; 148 rtc::scoped_refptr<VideoTrackInterface> track_;
149 bool stopped_ = false;
134 RtpReceiverObserverInterface* observer_ = nullptr; 150 RtpReceiverObserverInterface* observer_ = nullptr;
135 bool received_first_packet_ = false; 151 bool received_first_packet_ = false;
136 }; 152 };
137 153
138 } // namespace webrtc 154 } // namespace webrtc
139 155
140 #endif // WEBRTC_API_RTPRECEIVER_H_ 156 #endif // WEBRTC_API_RTPRECEIVER_H_
OLDNEW
« no previous file with comments | « webrtc/api/remoteaudiosource.cc ('k') | webrtc/api/rtpreceiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698