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

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

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Rebase Created 4 years 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 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 // This file contains classes that implement RtpReceiverInterface.
12 // An RtpReceiver associates a MediaStreamTrackInterface with an underlying
13 // transport (provided by cricket::VoiceChannel/cricket::VideoChannel)
14
15 #ifndef WEBRTC_API_RTPRECEIVER_H_
16 #define WEBRTC_API_RTPRECEIVER_H_
17
18 #include <string>
19
20 #include "webrtc/api/mediastreaminterface.h"
21 #include "webrtc/api/rtpreceiverinterface.h"
22 #include "webrtc/api/remoteaudiosource.h"
23 #include "webrtc/api/videotracksource.h"
24 #include "webrtc/base/basictypes.h"
25 #include "webrtc/base/sigslot.h"
26 #include "webrtc/media/base/videobroadcaster.h"
27 #include "webrtc/pc/channel.h"
28
29 namespace webrtc {
30
31 // Internal class used by PeerConnection.
32 class RtpReceiverInternal : public RtpReceiverInterface {
33 public:
34 virtual void Stop() = 0;
35 };
36
37 class AudioRtpReceiver : public ObserverInterface,
38 public AudioSourceInterface::AudioObserver,
39 public rtc::RefCountedObject<RtpReceiverInternal>,
40 public sigslot::has_slots<> {
41 public:
42 AudioRtpReceiver(MediaStreamInterface* stream,
43 const std::string& track_id,
44 uint32_t ssrc,
45 cricket::VoiceChannel* channel);
46
47 virtual ~AudioRtpReceiver();
48
49 // ObserverInterface implementation
50 void OnChanged() override;
51
52 // AudioSourceInterface::AudioObserver implementation
53 void OnSetVolume(double volume) override;
54
55 rtc::scoped_refptr<AudioTrackInterface> audio_track() const {
56 return track_.get();
57 }
58
59 // RtpReceiverInterface implementation
60 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
61 return track_.get();
62 }
63
64 cricket::MediaType media_type() const override {
65 return cricket::MEDIA_TYPE_AUDIO;
66 }
67
68 std::string id() const override { return id_; }
69
70 RtpParameters GetParameters() const override;
71 bool SetParameters(const RtpParameters& parameters) override;
72
73 // RtpReceiverInternal implementation.
74 void Stop() override;
75
76 void SetObserver(RtpReceiverObserverInterface* observer) override;
77
78 // Does not take ownership.
79 // Should call SetChannel(nullptr) before |channel| is destroyed.
80 void SetChannel(cricket::VoiceChannel* channel);
81
82 private:
83 void Reconfigure();
84 void OnFirstPacketReceived(cricket::BaseChannel* channel);
85
86 const std::string id_;
87 const uint32_t ssrc_;
88 cricket::VoiceChannel* channel_;
89 const rtc::scoped_refptr<AudioTrackInterface> track_;
90 bool cached_track_enabled_;
91 double cached_volume_ = 1;
92 bool stopped_ = false;
93 RtpReceiverObserverInterface* observer_ = nullptr;
94 bool received_first_packet_ = false;
95 };
96
97 class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal>,
98 public sigslot::has_slots<> {
99 public:
100 VideoRtpReceiver(MediaStreamInterface* stream,
101 const std::string& track_id,
102 rtc::Thread* worker_thread,
103 uint32_t ssrc,
104 cricket::VideoChannel* channel);
105
106 virtual ~VideoRtpReceiver();
107
108 rtc::scoped_refptr<VideoTrackInterface> video_track() const {
109 return track_.get();
110 }
111
112 // RtpReceiverInterface implementation
113 rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
114 return track_.get();
115 }
116
117 cricket::MediaType media_type() const override {
118 return cricket::MEDIA_TYPE_VIDEO;
119 }
120
121 std::string id() const override { return id_; }
122
123 RtpParameters GetParameters() const override;
124 bool SetParameters(const RtpParameters& parameters) override;
125
126 // RtpReceiverInternal implementation.
127 void Stop() override;
128
129 void SetObserver(RtpReceiverObserverInterface* observer) override;
130
131 // Does not take ownership.
132 // Should call SetChannel(nullptr) before |channel| is destroyed.
133 void SetChannel(cricket::VideoChannel* channel);
134
135 private:
136 void OnFirstPacketReceived(cricket::BaseChannel* channel);
137
138 std::string id_;
139 uint32_t ssrc_;
140 cricket::VideoChannel* channel_;
141 // |broadcaster_| is needed since the decoder can only handle one sink.
142 // It might be better if the decoder can handle multiple sinks and consider
143 // the VideoSinkWants.
144 rtc::VideoBroadcaster broadcaster_;
145 // |source_| is held here to be able to change the state of the source when
146 // the VideoRtpReceiver is stopped.
147 rtc::scoped_refptr<VideoTrackSource> source_;
148 rtc::scoped_refptr<VideoTrackInterface> track_;
149 bool stopped_ = false;
150 RtpReceiverObserverInterface* observer_ = nullptr;
151 bool received_first_packet_ = false;
152 };
153
154 } // namespace webrtc
155
156 #endif // WEBRTC_API_RTPRECEIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698