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

Side by Side Diff: talk/app/webrtc/rtpsender.h

Issue 1610243002: Move talk/app/webrtc to webrtc/api (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed processing of api.gyp for Chromium builds Created 4 years, 10 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 | « talk/app/webrtc/rtpreceiverinterface.h ('k') | talk/app/webrtc/rtpsender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * libjingle
3 * Copyright 2015 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 // This file contains classes that implement RtpSenderInterface.
29 // An RtpSender associates a MediaStreamTrackInterface with an underlying
30 // transport (provided by AudioProviderInterface/VideoProviderInterface)
31
32 #ifndef TALK_APP_WEBRTC_RTPSENDER_H_
33 #define TALK_APP_WEBRTC_RTPSENDER_H_
34
35 #include <string>
36
37 #include "talk/app/webrtc/mediastreamprovider.h"
38 #include "talk/app/webrtc/rtpsenderinterface.h"
39 #include "talk/app/webrtc/statscollector.h"
40 #include "webrtc/base/basictypes.h"
41 #include "webrtc/base/criticalsection.h"
42 #include "webrtc/base/scoped_ptr.h"
43 #include "webrtc/media/base/audiorenderer.h"
44
45 namespace webrtc {
46
47 // LocalAudioSinkAdapter receives data callback as a sink to the local
48 // AudioTrack, and passes the data to the sink of AudioRenderer.
49 class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
50 public cricket::AudioRenderer {
51 public:
52 LocalAudioSinkAdapter();
53 virtual ~LocalAudioSinkAdapter();
54
55 private:
56 // AudioSinkInterface implementation.
57 void OnData(const void* audio_data,
58 int bits_per_sample,
59 int sample_rate,
60 size_t number_of_channels,
61 size_t number_of_frames) override;
62
63 // cricket::AudioRenderer implementation.
64 void SetSink(cricket::AudioRenderer::Sink* sink) override;
65
66 cricket::AudioRenderer::Sink* sink_;
67 // Critical section protecting |sink_|.
68 rtc::CriticalSection lock_;
69 };
70
71 class AudioRtpSender : public ObserverInterface,
72 public rtc::RefCountedObject<RtpSenderInterface> {
73 public:
74 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
75 // at the appropriate times.
76 AudioRtpSender(AudioTrackInterface* track,
77 const std::string& stream_id,
78 AudioProviderInterface* provider,
79 StatsCollector* stats);
80
81 // Randomly generates stream_id.
82 AudioRtpSender(AudioTrackInterface* track,
83 AudioProviderInterface* provider,
84 StatsCollector* stats);
85
86 // Randomly generates id and stream_id.
87 AudioRtpSender(AudioProviderInterface* provider, StatsCollector* stats);
88
89 virtual ~AudioRtpSender();
90
91 // ObserverInterface implementation
92 void OnChanged() override;
93
94 // RtpSenderInterface implementation
95 bool SetTrack(MediaStreamTrackInterface* track) override;
96 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
97 return track_.get();
98 }
99
100 void SetSsrc(uint32_t ssrc) override;
101
102 uint32_t ssrc() const override { return ssrc_; }
103
104 cricket::MediaType media_type() const override {
105 return cricket::MEDIA_TYPE_AUDIO;
106 }
107
108 std::string id() const override { return id_; }
109
110 void set_stream_id(const std::string& stream_id) override {
111 stream_id_ = stream_id;
112 }
113 std::string stream_id() const override { return stream_id_; }
114
115 void Stop() override;
116
117 private:
118 bool can_send_track() const { return track_ && ssrc_; }
119 // Helper function to construct options for
120 // AudioProviderInterface::SetAudioSend.
121 void SetAudioSend();
122
123 std::string id_;
124 std::string stream_id_;
125 AudioProviderInterface* provider_;
126 StatsCollector* stats_;
127 rtc::scoped_refptr<AudioTrackInterface> track_;
128 uint32_t ssrc_ = 0;
129 bool cached_track_enabled_ = false;
130 bool stopped_ = false;
131
132 // Used to pass the data callback from the |track_| to the other end of
133 // cricket::AudioRenderer.
134 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_;
135 };
136
137 class VideoRtpSender : public ObserverInterface,
138 public rtc::RefCountedObject<RtpSenderInterface> {
139 public:
140 VideoRtpSender(VideoTrackInterface* track,
141 const std::string& stream_id,
142 VideoProviderInterface* provider);
143
144 // Randomly generates stream_id.
145 VideoRtpSender(VideoTrackInterface* track, VideoProviderInterface* provider);
146
147 // Randomly generates id and stream_id.
148 explicit VideoRtpSender(VideoProviderInterface* provider);
149
150 virtual ~VideoRtpSender();
151
152 // ObserverInterface implementation
153 void OnChanged() override;
154
155 // RtpSenderInterface implementation
156 bool SetTrack(MediaStreamTrackInterface* track) override;
157 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
158 return track_.get();
159 }
160
161 void SetSsrc(uint32_t ssrc) override;
162
163 uint32_t ssrc() const override { return ssrc_; }
164
165 cricket::MediaType media_type() const override {
166 return cricket::MEDIA_TYPE_VIDEO;
167 }
168
169 std::string id() const override { return id_; }
170
171 void set_stream_id(const std::string& stream_id) override {
172 stream_id_ = stream_id;
173 }
174 std::string stream_id() const override { return stream_id_; }
175
176 void Stop() override;
177
178 private:
179 bool can_send_track() const { return track_ && ssrc_; }
180 // Helper function to construct options for
181 // VideoProviderInterface::SetVideoSend.
182 void SetVideoSend();
183
184 std::string id_;
185 std::string stream_id_;
186 VideoProviderInterface* provider_;
187 rtc::scoped_refptr<VideoTrackInterface> track_;
188 uint32_t ssrc_ = 0;
189 bool cached_track_enabled_ = false;
190 bool stopped_ = false;
191 };
192
193 } // namespace webrtc
194
195 #endif // TALK_APP_WEBRTC_RTPSENDER_H_
OLDNEW
« no previous file with comments | « talk/app/webrtc/rtpreceiverinterface.h ('k') | talk/app/webrtc/rtpsender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698