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

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: Fixing indentation. Created 5 years, 2 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 virtual void DetachFromProvider() = 0;
49
50 protected:
51 virtual ~BaseRtpSender() {}
52 };
53
54 // LocalAudioSinkAdapter receives data callback as a sink to the local
55 // AudioTrack, and passes the data to the sink of AudioRenderer.
56 class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
57 public cricket::AudioRenderer {
58 public:
59 LocalAudioSinkAdapter();
60 virtual ~LocalAudioSinkAdapter();
61
62 private:
63 // AudioSinkInterface implementation.
64 void OnData(const void* audio_data,
65 int bits_per_sample,
66 int sample_rate,
67 int number_of_channels,
68 size_t number_of_frames) override;
69
70 // cricket::AudioRenderer implementation.
71 void SetSink(cricket::AudioRenderer::Sink* sink) override;
72
73 cricket::AudioRenderer::Sink* sink_;
74 // Critical section protecting |sink_|.
75 rtc::CriticalSection lock_;
76 };
77
78 class AudioRtpSender : public ObserverInterface, public BaseRtpSender {
79 public:
80 AudioRtpSender(AudioTrackInterface* track,
81 uint32 ssrc,
82 AudioProviderInterface* provider);
83
84 virtual ~AudioRtpSender();
85
86 // ObserverInterface implementation
87 void OnChanged() override;
88
89 // RtpSenderInterface implementation
90 void SetTrack(MediaStreamTrackInterface* track) override;
91 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
92 return track_.get();
93 }
94
95 void DetachFromProvider() override;
96
97 private:
98 void UpdateProvider();
99
100 rtc::scoped_refptr<AudioTrackInterface> track_;
101 uint32 ssrc_;
102 AudioProviderInterface* provider_;
103 bool cached_track_enabled_;
104
105 // Used to pass the data callback from the |track_| to the other end of
106 // cricket::AudioRenderer.
107 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_;
108 };
109
110 class VideoRtpSender : public ObserverInterface, public BaseRtpSender {
111 public:
112 VideoRtpSender(VideoTrackInterface* track,
113 uint32 ssrc,
114 VideoProviderInterface* provider);
115
116 virtual ~VideoRtpSender();
117
118 // ObserverInterface implementation
119 void OnChanged() override;
120
121 // RtpSenderInterface implementation
122 void SetTrack(MediaStreamTrackInterface* track) override;
123 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
124 return track_.get();
125 }
126
127 void DetachFromProvider() override;
128
129 private:
130 void UpdateProvider();
131
132 rtc::scoped_refptr<VideoTrackInterface> track_;
133 uint32 ssrc_;
134 VideoProviderInterface* provider_;
135 bool cached_track_enabled_;
136 };
137
138 } // namespace webrtc
139
140 #endif // TALK_APP_WEBRTC_RTPSENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698