| OLD | NEW | 
|    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 #include "webrtc/api/rtpreceiver.h" |   11 #include "webrtc/api/rtpreceiver.h" | 
|   12  |   12  | 
|   13 #include "webrtc/api/videosourceinterface.h" |   13 #include "webrtc/api/mediastreamtrackproxy.h" | 
 |   14 #include "webrtc/api/videotrack.h" | 
|   14  |   15  | 
|   15 namespace webrtc { |   16 namespace webrtc { | 
|   16  |   17  | 
|   17 AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track, |   18 AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track, | 
|   18                                    uint32_t ssrc, |   19                                    uint32_t ssrc, | 
|   19                                    AudioProviderInterface* provider) |   20                                    AudioProviderInterface* provider) | 
|   20     : id_(track->id()), |   21     : id_(track->id()), | 
|   21       track_(track), |   22       track_(track), | 
|   22       ssrc_(ssrc), |   23       ssrc_(ssrc), | 
|   23       provider_(provider), |   24       provider_(provider), | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   58   provider_ = nullptr; |   59   provider_ = nullptr; | 
|   59 } |   60 } | 
|   60  |   61  | 
|   61 void AudioRtpReceiver::Reconfigure() { |   62 void AudioRtpReceiver::Reconfigure() { | 
|   62   if (!provider_) { |   63   if (!provider_) { | 
|   63     return; |   64     return; | 
|   64   } |   65   } | 
|   65   provider_->SetAudioPlayout(ssrc_, track_->enabled()); |   66   provider_->SetAudioPlayout(ssrc_, track_->enabled()); | 
|   66 } |   67 } | 
|   67  |   68  | 
|   68 VideoRtpReceiver::VideoRtpReceiver(VideoTrackInterface* track, |   69 VideoRtpReceiver::VideoRtpReceiver(MediaStreamInterface* stream, | 
 |   70                                    const std::string& track_id, | 
 |   71                                    rtc::Thread* worker_thread, | 
|   69                                    uint32_t ssrc, |   72                                    uint32_t ssrc, | 
|   70                                    VideoProviderInterface* provider) |   73                                    VideoProviderInterface* provider) | 
|   71     : id_(track->id()), track_(track), ssrc_(ssrc), provider_(provider) { |   74     : id_(track_id), | 
|   72   provider_->SetVideoPlayout(ssrc_, true, track_->GetSink()); |   75       ssrc_(ssrc), | 
 |   76       provider_(provider), | 
 |   77       source_(new RefCountedObject<VideoTrackSource>(&broadcaster_, | 
 |   78                                                      worker_thread, | 
 |   79                                                      true /* remote */)), | 
 |   80       track_(VideoTrackProxy::Create( | 
 |   81           rtc::Thread::Current(), | 
 |   82           VideoTrack::Create(track_id, source_.get()))) { | 
 |   83   source_->SetState(MediaSourceInterface::kLive); | 
 |   84   // TODO(perkj): It should be enough to set the source state. All tracks | 
 |   85   // belonging to the same source should get its state from the source. | 
 |   86   // I.e. if a track has been cloned from a remote source. | 
 |   87   track_->set_state(webrtc::MediaStreamTrackInterface::kLive); | 
 |   88   provider_->SetVideoPlayout(ssrc_, true, &broadcaster_); | 
 |   89   stream->AddTrack(track_); | 
|   73 } |   90 } | 
|   74  |   91  | 
|   75 VideoRtpReceiver::~VideoRtpReceiver() { |   92 VideoRtpReceiver::~VideoRtpReceiver() { | 
|   76   // Since cricket::VideoRenderer is not reference counted, |   93   // Since cricket::VideoRenderer is not reference counted, | 
|   77   // we need to remove it from the provider before we are deleted. |   94   // we need to remove it from the provider before we are deleted. | 
|   78   Stop(); |   95   Stop(); | 
|   79 } |   96 } | 
|   80  |   97  | 
|   81 void VideoRtpReceiver::Stop() { |   98 void VideoRtpReceiver::Stop() { | 
|   82   // TODO(deadbeef): Need to do more here to fully stop receiving packets. |   99   // TODO(deadbeef): Need to do more here to fully stop receiving packets. | 
|   83   if (!provider_) { |  100   if (!provider_) { | 
|   84     return; |  101     return; | 
|   85   } |  102   } | 
 |  103   source_->SetState(MediaSourceInterface::kEnded); | 
 |  104   source_->OnSourceDestroyed(); | 
 |  105   // TODO(perkj): It should be enough to set the source state. All tracks | 
 |  106   // belonging to the same source should get its state from the source. | 
 |  107   track_->set_state(MediaStreamTrackInterface::kEnded); | 
|   86   provider_->SetVideoPlayout(ssrc_, false, nullptr); |  108   provider_->SetVideoPlayout(ssrc_, false, nullptr); | 
|   87   provider_ = nullptr; |  109   provider_ = nullptr; | 
|   88 } |  110 } | 
|   89  |  111  | 
|   90 }  // namespace webrtc |  112 }  // namespace webrtc | 
| OLD | NEW |