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

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

Issue 1351803002: Exposing RtpSenders and RtpReceivers from PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Return bool from RtpSenderInterface::SetTrack. Created 5 years, 3 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
(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/media/base/audiorenderer.h"
40 #include "webrtc/base/basictypes.h"
41 #include "webrtc/base/criticalsection.h"
42 #include "webrtc/base/scoped_ptr.h"
43
44 namespace webrtc {
45
46 class BaseRtpSender : public rtc::RefCountedObject<RtpSenderInterface> {
47 public:
48 explicit BaseRtpSender(const std::string& id) : id_(id) {}
49 virtual void DetachFromProvider() = 0;
50
51 std::string id() const override { return id_; }
52
53 protected:
54 virtual ~BaseRtpSender() {}
55
56 private:
57 std::string id_;
58 };
59
60 // LocalAudioSinkAdapter receives data callback as a sink to the local
61 // AudioTrack, and passes the data to the sink of AudioRenderer.
62 class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
63 public cricket::AudioRenderer {
64 public:
65 LocalAudioSinkAdapter();
66 virtual ~LocalAudioSinkAdapter();
67
68 private:
69 // AudioSinkInterface implementation.
70 void OnData(const void* audio_data,
71 int bits_per_sample,
72 int sample_rate,
73 int number_of_channels,
74 size_t number_of_frames) override;
75
76 // cricket::AudioRenderer implementation.
77 void SetSink(cricket::AudioRenderer::Sink* sink) override;
78
79 cricket::AudioRenderer::Sink* sink_;
80 // Critical section protecting |sink_|.
81 rtc::CriticalSection lock_;
82 };
83
84 class AudioRtpSender : public ObserverInterface, public BaseRtpSender {
85 public:
86 AudioRtpSender(AudioTrackInterface* track,
87 uint32 ssrc,
88 AudioProviderInterface* provider);
89
90 virtual ~AudioRtpSender();
91
92 // ObserverInterface implementation
93 void OnChanged() override;
94
95 // RtpSenderInterface implementation
96 bool SetTrack(MediaStreamTrackInterface* track) override;
97 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
98 return track_.get();
99 }
100
101 void DetachFromProvider() override;
102
103 private:
104 void UpdateProvider();
105
106 rtc::scoped_refptr<AudioTrackInterface> track_;
107 uint32 ssrc_;
108 AudioProviderInterface* provider_;
109 bool cached_track_enabled_;
110
111 // Used to pass the data callback from the |track_| to the other end of
112 // cricket::AudioRenderer.
113 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_;
114 };
115
116 class VideoRtpSender : public ObserverInterface, public BaseRtpSender {
117 public:
118 VideoRtpSender(VideoTrackInterface* track,
119 uint32 ssrc,
120 VideoProviderInterface* provider);
121
122 virtual ~VideoRtpSender();
123
124 // ObserverInterface implementation
125 void OnChanged() override;
126
127 // RtpSenderInterface implementation
128 bool SetTrack(MediaStreamTrackInterface* track) override;
129 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
130 return track_.get();
131 }
132
133 void DetachFromProvider() override;
134
135 private:
136 void UpdateProvider();
137
138 rtc::scoped_refptr<VideoTrackInterface> track_;
139 uint32 ssrc_;
140 VideoProviderInterface* provider_;
141 bool cached_track_enabled_;
142 };
143
144 } // namespace webrtc
145
146 #endif // TALK_APP_WEBRTC_RTPSENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698