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

Side by Side Diff: chrome/renderer/media/cast_rtp_stream.cc

Issue 1873293002: Report if video capturing meets output protection requirement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed oshima and nasko's comments, and rebased. Created 4 years, 7 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 // 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 consecutive_refresh_count_(0), 338 consecutive_refresh_count_(0),
339 expecting_a_refresh_frame_(false) {} 339 expecting_a_refresh_frame_(false) {}
340 340
341 ~CastVideoSink() override { 341 ~CastVideoSink() override {
342 MediaStreamVideoSink::DisconnectFromTrack(); 342 MediaStreamVideoSink::DisconnectFromTrack();
343 } 343 }
344 344
345 // Attach this sink to a video track represented by |track_|. 345 // Attach this sink to a video track represented by |track_|.
346 // Data received from the track will be submitted to |frame_input|. 346 // Data received from the track will be submitted to |frame_input|.
347 void AddToTrack( 347 void AddToTrack(
348 bool is_sink_secure,
348 const scoped_refptr<media::cast::VideoFrameInput>& frame_input) { 349 const scoped_refptr<media::cast::VideoFrameInput>& frame_input) {
349 DCHECK(deliverer_); 350 DCHECK(deliverer_);
350 deliverer_->WillConnectToTrack(AsWeakPtr(), frame_input); 351 deliverer_->WillConnectToTrack(AsWeakPtr(), frame_input);
351 refresh_timer_.Start( 352 refresh_timer_.Start(
352 FROM_HERE, 353 FROM_HERE,
353 base::TimeDelta::FromMilliseconds(kRefreshIntervalMilliseconds), 354 base::TimeDelta::FromMilliseconds(kRefreshIntervalMilliseconds),
354 base::Bind(&CastVideoSink::OnRefreshTimerFired, 355 base::Bind(&CastVideoSink::OnRefreshTimerFired,
355 base::Unretained(this))); 356 base::Unretained(this)));
356 MediaStreamVideoSink::ConnectToTrack(track_, 357 MediaStreamVideoSink::ConnectToTrack(
357 base::Bind(&Deliverer::OnVideoFrame, 358 track_, base::Bind(&Deliverer::OnVideoFrame, deliverer_),
358 deliverer_)); 359 is_sink_secure);
359 } 360 }
360 361
361 private: 362 private:
362 class Deliverer : public base::RefCountedThreadSafe<Deliverer> { 363 class Deliverer : public base::RefCountedThreadSafe<Deliverer> {
363 public: 364 public:
364 explicit Deliverer(const CastRtpStream::ErrorCallback& error_callback) 365 explicit Deliverer(const CastRtpStream::ErrorCallback& error_callback)
365 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 366 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
366 error_callback_(error_callback) {} 367 error_callback_(error_callback) {}
367 368
368 void WillConnectToTrack( 369 void WillConnectToTrack(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 if (!ToVideoSenderConfig(params, &config)) { 679 if (!ToVideoSenderConfig(params, &config)) {
679 DidEncounterError("Invalid parameters for video."); 680 DidEncounterError("Invalid parameters for video.");
680 return; 681 return;
681 } 682 }
682 // See the code for audio above for explanation of callbacks. 683 // See the code for audio above for explanation of callbacks.
683 video_sink_.reset(new CastVideoSink( 684 video_sink_.reset(new CastVideoSink(
684 track_, 685 track_,
685 media::BindToCurrentLoop(base::Bind(&CastRtpStream::DidEncounterError, 686 media::BindToCurrentLoop(base::Bind(&CastRtpStream::DidEncounterError,
686 weak_factory_.GetWeakPtr())))); 687 weak_factory_.GetWeakPtr()))));
687 cast_session_->StartVideo( 688 cast_session_->StartVideo(
688 config, 689 config, base::Bind(&CastVideoSink::AddToTrack, video_sink_->AsWeakPtr(),
689 base::Bind(&CastVideoSink::AddToTrack, video_sink_->AsWeakPtr()), 690 !params.payload.aes_key.empty()),
690 base::Bind(&CastRtpStream::DidEncounterError, 691 base::Bind(&CastRtpStream::DidEncounterError,
691 weak_factory_.GetWeakPtr())); 692 weak_factory_.GetWeakPtr()));
692 start_callback.Run(); 693 start_callback.Run();
693 } 694 }
694 } 695 }
695 696
696 void CastRtpStream::Stop() { 697 void CastRtpStream::Stop() {
697 DVLOG(1) << "CastRtpStream::Stop = " << (IsAudio() ? "audio" : "video"); 698 DVLOG(1) << "CastRtpStream::Stop = " << (IsAudio() ? "audio" : "video");
698 if (stop_callback_.is_null()) 699 if (stop_callback_.is_null())
699 return; // Already stopped. 700 return; // Already stopped.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 DCHECK(content::RenderThread::Get()); 735 DCHECK(content::RenderThread::Get());
735 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " 736 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = "
736 << (IsAudio() ? "audio" : "video"); 737 << (IsAudio() ? "audio" : "video");
737 // Save the WeakPtr first because the error callback might delete this object. 738 // Save the WeakPtr first because the error callback might delete this object.
738 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); 739 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr();
739 error_callback_.Run(message); 740 error_callback_.Run(message);
740 base::ThreadTaskRunnerHandle::Get()->PostTask( 741 base::ThreadTaskRunnerHandle::Get()->PostTask(
741 FROM_HERE, 742 FROM_HERE,
742 base::Bind(&CastRtpStream::Stop, ptr)); 743 base::Bind(&CastRtpStream::Stop, ptr));
743 } 744 }
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | content/browser/renderer_host/media/media_stream_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698