| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/media/cast_rtp_stream.h" | 5 #include "chrome/renderer/media/cast_rtp_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/renderer/media/cast_session.h" | 10 #include "chrome/renderer/media/cast_session.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 | 272 |
| 273 CastRtpParams::CastRtpParams() { | 273 CastRtpParams::CastRtpParams() { |
| 274 } | 274 } |
| 275 | 275 |
| 276 CastRtpParams::~CastRtpParams() { | 276 CastRtpParams::~CastRtpParams() { |
| 277 } | 277 } |
| 278 | 278 |
| 279 CastRtpStream::CastRtpStream(const blink::WebMediaStreamTrack& track, | 279 CastRtpStream::CastRtpStream(const blink::WebMediaStreamTrack& track, |
| 280 const scoped_refptr<CastSession>& session) | 280 const scoped_refptr<CastSession>& session) |
| 281 : track_(track), cast_session_(session), weak_factory_(this) {} | 281 : track_(track), |
| 282 cast_session_(session), |
| 283 stream_id_(-1), |
| 284 weak_factory_(this) {} |
| 282 | 285 |
| 283 CastRtpStream::~CastRtpStream() { | 286 CastRtpStream::~CastRtpStream() { |
| 284 } | 287 } |
| 285 | 288 |
| 286 std::vector<CastRtpParams> CastRtpStream::GetSupportedParams() { | 289 std::vector<CastRtpParams> CastRtpStream::GetSupportedParams() { |
| 287 if (IsAudio()) | 290 if (IsAudio()) |
| 288 return SupportedAudioParams(); | 291 return SupportedAudioParams(); |
| 289 else | 292 else |
| 290 return SupportedVideoParams(); | 293 return SupportedVideoParams(); |
| 291 } | 294 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 start_callback.Run(); | 339 start_callback.Run(); |
| 337 } | 340 } |
| 338 } | 341 } |
| 339 | 342 |
| 340 void CastRtpStream::Stop() { | 343 void CastRtpStream::Stop() { |
| 341 audio_sink_.reset(); | 344 audio_sink_.reset(); |
| 342 video_sink_.reset(); | 345 video_sink_.reset(); |
| 343 stop_callback_.Run(); | 346 stop_callback_.Run(); |
| 344 } | 347 } |
| 345 | 348 |
| 349 void CastRtpStream::SetStreamId(const int stream_id) { |
| 350 DCHECK(stream_id >= 0); |
| 351 stream_id_ = stream_id; |
| 352 } |
| 353 |
| 354 void CastRtpStream::StartLogging() { |
| 355 DCHECK(stream_id_ >= 0); |
| 356 cast_session_->StartLogging(stream_id_, IsAudio()); |
| 357 } |
| 358 |
| 359 void CastRtpStream::GetRawEvents( |
| 360 base::Callback<void(scoped_ptr<std::string>)> callback) { |
| 361 DCHECK(stream_id_ >= 0); |
| 362 cast_session_->GetEventLogsAndReset(callback, stream_id_); |
| 363 } |
| 364 |
| 346 bool CastRtpStream::IsAudio() const { | 365 bool CastRtpStream::IsAudio() const { |
| 347 return track_.source().type() == blink::WebMediaStreamSource::TypeAudio; | 366 return track_.source().type() == blink::WebMediaStreamSource::TypeAudio; |
| 348 } | 367 } |
| 349 | 368 |
| 350 void CastRtpStream::DidEncounterError(const std::string& message) { | 369 void CastRtpStream::DidEncounterError(const std::string& message) { |
| 351 error_callback_.Run(message); | 370 error_callback_.Run(message); |
| 352 Stop(); | 371 Stop(); |
| 353 } | 372 } |
| OLD | NEW |