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

Side by Side Diff: webrtc/api/rtpreceiver.h

Issue 1999853002: Forward the SignalFirstPacketReceived to RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modified the unit test. Created 4 years, 6 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/peerconnection_unittest.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 AudioProviderInterface/VideoProviderInterface)
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/mediastreamprovider.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/media/base/videobroadcaster.h" 26 #include "webrtc/media/base/videobroadcaster.h"
26 27
27 namespace webrtc { 28 namespace webrtc {
28 29
29 // Internal class used by PeerConnection. 30 // Internal class used by PeerConnection.
30 class RtpReceiverInternal : public RtpReceiverInterface { 31 class RtpReceiverInternal : public RtpReceiverInterface {
31 public: 32 public:
32 virtual void Stop() = 0; 33 virtual void Stop() = 0;
33 }; 34 };
34 35
35 class AudioRtpReceiver : public ObserverInterface, 36 class AudioRtpReceiver : public ObserverInterface,
36 public AudioSourceInterface::AudioObserver, 37 public AudioSourceInterface::AudioObserver,
37 public rtc::RefCountedObject<RtpReceiverInternal> { 38 public rtc::RefCountedObject<RtpReceiverInternal>,
39 public sigslot::has_slots<> {
38 public: 40 public:
39 AudioRtpReceiver(MediaStreamInterface* stream, 41 AudioRtpReceiver(MediaStreamInterface* stream,
40 const std::string& track_id, 42 const std::string& track_id,
41 uint32_t ssrc, 43 uint32_t ssrc,
42 AudioProviderInterface* provider); 44 AudioProviderInterface* provider);
43 45
44 virtual ~AudioRtpReceiver(); 46 virtual ~AudioRtpReceiver();
45 47
46 // ObserverInterface implementation 48 // ObserverInterface implementation
47 void OnChanged() override; 49 void OnChanged() override;
(...skipping 11 matching lines...) Expand all
59 } 61 }
60 62
61 std::string id() const override { return id_; } 63 std::string id() const override { return id_; }
62 64
63 RtpParameters GetParameters() const override; 65 RtpParameters GetParameters() const override;
64 bool SetParameters(const RtpParameters& parameters) override; 66 bool SetParameters(const RtpParameters& parameters) override;
65 67
66 // RtpReceiverInternal implementation. 68 // RtpReceiverInternal implementation.
67 void Stop() override; 69 void Stop() override;
68 70
71 void SetObserver(RtpReceiverObserverInterface* observer) override;
72
73 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; }
74
69 private: 75 private:
70 void Reconfigure(); 76 void Reconfigure();
77 void OnFirstAudioPacketReceived();
71 78
72 const std::string id_; 79 const std::string id_;
73 const uint32_t ssrc_; 80 const uint32_t ssrc_;
74 AudioProviderInterface* provider_; // Set to null in Stop(). 81 AudioProviderInterface* provider_; // Set to null in Stop().
75 const rtc::scoped_refptr<AudioTrackInterface> track_; 82 const rtc::scoped_refptr<AudioTrackInterface> track_;
76 bool cached_track_enabled_; 83 bool cached_track_enabled_;
84 RtpReceiverObserverInterface* observer_ = nullptr;
85 bool received_first_packet_ = false;
77 }; 86 };
78 87
79 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> { 88 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal>,
89 public sigslot::has_slots<> {
80 public: 90 public:
81 VideoRtpReceiver(MediaStreamInterface* stream, 91 VideoRtpReceiver(MediaStreamInterface* stream,
82 const std::string& track_id, 92 const std::string& track_id,
83 rtc::Thread* worker_thread, 93 rtc::Thread* worker_thread,
84 uint32_t ssrc, 94 uint32_t ssrc,
85 VideoProviderInterface* provider); 95 VideoProviderInterface* provider);
86 96
87 virtual ~VideoRtpReceiver(); 97 virtual ~VideoRtpReceiver();
88 98
89 rtc::scoped_refptr<VideoTrackInterface> video_track() const { 99 rtc::scoped_refptr<VideoTrackInterface> video_track() const {
90 return track_.get(); 100 return track_.get();
91 } 101 }
92 102
93 // RtpReceiverInterface implementation 103 // RtpReceiverInterface implementation
94 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override { 104 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
95 return track_.get(); 105 return track_.get();
96 } 106 }
97 107
98 std::string id() const override { return id_; } 108 std::string id() const override { return id_; }
99 109
100 RtpParameters GetParameters() const override; 110 RtpParameters GetParameters() const override;
101 bool SetParameters(const RtpParameters& parameters) override; 111 bool SetParameters(const RtpParameters& parameters) override;
102 112
103 // RtpReceiverInternal implementation. 113 // RtpReceiverInternal implementation.
104 void Stop() override; 114 void Stop() override;
105 115
116 void SetObserver(RtpReceiverObserverInterface* observer) override;
117
118 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; }
119
106 private: 120 private:
121 void OnFirstVideoPacketReceived();
122
107 std::string id_; 123 std::string id_;
108 uint32_t ssrc_; 124 uint32_t ssrc_;
109 VideoProviderInterface* provider_; 125 VideoProviderInterface* provider_;
110 // |broadcaster_| is needed since the decoder can only handle one sink. 126 // |broadcaster_| is needed since the decoder can only handle one sink.
111 // It might be better if the decoder can handle multiple sinks and consider 127 // It might be better if the decoder can handle multiple sinks and consider
112 // the VideoSinkWants. 128 // the VideoSinkWants.
113 rtc::VideoBroadcaster broadcaster_; 129 rtc::VideoBroadcaster broadcaster_;
114 // |source_| is held here to be able to change the state of the source when 130 // |source_| is held here to be able to change the state of the source when
115 // the VideoRtpReceiver is stopped. 131 // the VideoRtpReceiver is stopped.
116 rtc::scoped_refptr<VideoTrackSource> source_; 132 rtc::scoped_refptr<VideoTrackSource> source_;
117 rtc::scoped_refptr<VideoTrackInterface> track_; 133 rtc::scoped_refptr<VideoTrackInterface> track_;
134 RtpReceiverObserverInterface* observer_ = nullptr;
135 bool received_first_packet_ = false;
118 }; 136 };
119 137
120 } // namespace webrtc 138 } // namespace webrtc
121 139
122 #endif // WEBRTC_API_RTPRECEIVER_H_ 140 #endif // WEBRTC_API_RTPRECEIVER_H_
OLDNEW
« no previous file with comments | « webrtc/api/peerconnection_unittest.cc ('k') | webrtc/api/rtpreceiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698