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

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

Issue 1413713003: Adding the ability to create an RtpSender without a track. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Adding some unit tests for new methods on the sender. 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
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 18 matching lines...) Expand all
29 // An RtpSender associates a MediaStreamTrackInterface with an underlying 29 // An RtpSender associates a MediaStreamTrackInterface with an underlying
30 // transport (provided by AudioProviderInterface/VideoProviderInterface) 30 // transport (provided by AudioProviderInterface/VideoProviderInterface)
31 31
32 #ifndef TALK_APP_WEBRTC_RTPSENDER_H_ 32 #ifndef TALK_APP_WEBRTC_RTPSENDER_H_
33 #define TALK_APP_WEBRTC_RTPSENDER_H_ 33 #define TALK_APP_WEBRTC_RTPSENDER_H_
34 34
35 #include <string> 35 #include <string>
36 36
37 #include "talk/app/webrtc/mediastreamprovider.h" 37 #include "talk/app/webrtc/mediastreamprovider.h"
38 #include "talk/app/webrtc/rtpsenderinterface.h" 38 #include "talk/app/webrtc/rtpsenderinterface.h"
39 #include "talk/app/webrtc/statscollector.h"
39 #include "talk/media/base/audiorenderer.h" 40 #include "talk/media/base/audiorenderer.h"
40 #include "webrtc/base/basictypes.h" 41 #include "webrtc/base/basictypes.h"
41 #include "webrtc/base/criticalsection.h" 42 #include "webrtc/base/criticalsection.h"
42 #include "webrtc/base/scoped_ptr.h" 43 #include "webrtc/base/scoped_ptr.h"
43 44
44 namespace webrtc { 45 namespace webrtc {
45 46
46 // LocalAudioSinkAdapter receives data callback as a sink to the local 47 // LocalAudioSinkAdapter receives data callback as a sink to the local
47 // AudioTrack, and passes the data to the sink of AudioRenderer. 48 // AudioTrack, and passes the data to the sink of AudioRenderer.
48 class LocalAudioSinkAdapter : public AudioTrackSinkInterface, 49 class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
(...skipping 14 matching lines...) Expand all
63 void SetSink(cricket::AudioRenderer::Sink* sink) override; 64 void SetSink(cricket::AudioRenderer::Sink* sink) override;
64 65
65 cricket::AudioRenderer::Sink* sink_; 66 cricket::AudioRenderer::Sink* sink_;
66 // Critical section protecting |sink_|. 67 // Critical section protecting |sink_|.
67 rtc::CriticalSection lock_; 68 rtc::CriticalSection lock_;
68 }; 69 };
69 70
70 class AudioRtpSender : public ObserverInterface, 71 class AudioRtpSender : public ObserverInterface,
71 public rtc::RefCountedObject<RtpSenderInterface> { 72 public rtc::RefCountedObject<RtpSenderInterface> {
72 public: 73 public:
74 // StatsCollector provided so that Add/RemoveLocalAudioTrack can be called
75 // at the appropriate times.
73 AudioRtpSender(AudioTrackInterface* track, 76 AudioRtpSender(AudioTrackInterface* track,
74 uint32_t ssrc, 77 const std::string& stream_id,
75 AudioProviderInterface* provider); 78 AudioProviderInterface* provider,
79 StatsCollector* stats);
80
81 // Randomly generates id and stream_id.
82 AudioRtpSender(AudioProviderInterface* provider, StatsCollector* stats);
76 83
77 virtual ~AudioRtpSender(); 84 virtual ~AudioRtpSender();
78 85
79 // ObserverInterface implementation 86 // ObserverInterface implementation
80 void OnChanged() override; 87 void OnChanged() override;
81 88
82 // RtpSenderInterface implementation 89 // RtpSenderInterface implementation
83 bool SetTrack(MediaStreamTrackInterface* track) override; 90 bool SetTrack(MediaStreamTrackInterface* track) override;
84 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 91 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
85 return track_.get(); 92 return track_.get();
86 } 93 }
87 94
95 void SetSsrc(uint32_t ssrc) override;
96
97 uint32_t ssrc() const override { return ssrc_; }
98
99 std::string kind() const override { return "audio"; }
100
88 std::string id() const override { return id_; } 101 std::string id() const override { return id_; }
89 102
103 void set_stream_id(const std::string& stream_id) override {
104 stream_id_ = stream_id;
105 }
106 std::string stream_id() const override { return stream_id_; }
107
90 void Stop() override; 108 void Stop() override;
91 109
92 private: 110 private:
93 void Reconfigure(); 111 // Helper function to construct options for
112 // AudioProviderInterface::SetAudioSend.
113 void SetAudioSend();
94 114
95 std::string id_; 115 std::string id_;
116 std::string stream_id_;
117 AudioProviderInterface* provider_;
118 StatsCollector* stats_;
96 rtc::scoped_refptr<AudioTrackInterface> track_; 119 rtc::scoped_refptr<AudioTrackInterface> track_;
97 uint32_t ssrc_; 120 uint32_t ssrc_ = 0;
pthatcher1 2015/10/20 17:42:49 Can you put a comment about how 0 is "unset" and w
Taylor Brandstetter 2015/10/21 00:22:08 It's in rtpsenderinterface.h.
98 AudioProviderInterface* provider_; 121 bool cached_track_enabled_ = false;
99 bool cached_track_enabled_; 122 bool stopped_ = false;
100 123
101 // Used to pass the data callback from the |track_| to the other end of 124 // Used to pass the data callback from the |track_| to the other end of
102 // cricket::AudioRenderer. 125 // cricket::AudioRenderer.
103 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_; 126 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_;
104 }; 127 };
105 128
106 class VideoRtpSender : public ObserverInterface, 129 class VideoRtpSender : public ObserverInterface,
107 public rtc::RefCountedObject<RtpSenderInterface> { 130 public rtc::RefCountedObject<RtpSenderInterface> {
108 public: 131 public:
109 VideoRtpSender(VideoTrackInterface* track, 132 VideoRtpSender(VideoTrackInterface* track,
110 uint32_t ssrc, 133 const std::string& stream_id,
111 VideoProviderInterface* provider); 134 VideoProviderInterface* provider);
112 135
136 // Randomly generates id and stream_id.
137 explicit VideoRtpSender(VideoProviderInterface* provider);
138
113 virtual ~VideoRtpSender(); 139 virtual ~VideoRtpSender();
114 140
115 // ObserverInterface implementation 141 // ObserverInterface implementation
116 void OnChanged() override; 142 void OnChanged() override;
117 143
118 // RtpSenderInterface implementation 144 // RtpSenderInterface implementation
119 bool SetTrack(MediaStreamTrackInterface* track) override; 145 bool SetTrack(MediaStreamTrackInterface* track) override;
120 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 146 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
121 return track_.get(); 147 return track_.get();
122 } 148 }
123 149
150 void SetSsrc(uint32_t ssrc) override;
151
152 uint32_t ssrc() const override { return ssrc_; }
153
154 std::string kind() const override { return "video"; }
155
124 std::string id() const override { return id_; } 156 std::string id() const override { return id_; }
125 157
158 void set_stream_id(const std::string& stream_id) override {
159 stream_id_ = stream_id;
160 }
161 std::string stream_id() const override { return stream_id_; }
162
126 void Stop() override; 163 void Stop() override;
127 164
128 private: 165 private:
129 void Reconfigure(); 166 // Helper function to construct options for
167 // VideoProviderInterface::SetVideoSend.
168 void SetVideoSend();
130 169
131 std::string id_; 170 std::string id_;
171 std::string stream_id_;
172 VideoProviderInterface* provider_;
132 rtc::scoped_refptr<VideoTrackInterface> track_; 173 rtc::scoped_refptr<VideoTrackInterface> track_;
133 uint32_t ssrc_; 174 uint32_t ssrc_ = 0;
134 VideoProviderInterface* provider_; 175 bool cached_track_enabled_ = false;
135 bool cached_track_enabled_; 176 bool stopped_ = false;
136 }; 177 };
137 178
138 } // namespace webrtc 179 } // namespace webrtc
139 180
140 #endif // TALK_APP_WEBRTC_RTPSENDER_H_ 181 #endif // TALK_APP_WEBRTC_RTPSENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698