OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/pepper/pepper_media_stream_video_track_host.h" | 5 #include "content/renderer/pepper/pepper_media_stream_video_track_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 new FrameDeliverer(io_task_runner(), frame_callback); | 436 new FrameDeliverer(io_task_runner(), frame_callback); |
437 } | 437 } |
438 } | 438 } |
439 | 439 |
440 void StopSourceImpl() final { | 440 void StopSourceImpl() final { |
441 if (host_) | 441 if (host_) |
442 host_->frame_deliverer_ = nullptr; | 442 host_->frame_deliverer_ = nullptr; |
443 } | 443 } |
444 | 444 |
445 private: | 445 private: |
| 446 base::Optional<media::VideoCaptureFormat> GetCurrentFormatImpl() |
| 447 const override { |
| 448 DCHECK(!IsOldVideoConstraints()); |
| 449 if (host_) { |
| 450 return media::VideoCaptureFormat( |
| 451 host_->plugin_frame_size_, kDefaultOutputFrameRate, |
| 452 ToPixelFormat(host_->plugin_frame_format_)); |
| 453 } |
| 454 return base::Optional<media::VideoCaptureFormat>(); |
| 455 } |
| 456 |
446 const base::WeakPtr<PepperMediaStreamVideoTrackHost> host_; | 457 const base::WeakPtr<PepperMediaStreamVideoTrackHost> host_; |
447 | 458 |
448 DISALLOW_COPY_AND_ASSIGN(VideoSource); | 459 DISALLOW_COPY_AND_ASSIGN(VideoSource); |
449 }; | 460 }; |
450 | 461 |
451 void PepperMediaStreamVideoTrackHost::DidConnectPendingHostToResource() { | 462 void PepperMediaStreamVideoTrackHost::DidConnectPendingHostToResource() { |
452 if (!MediaStreamVideoSink::connected_track().isNull()) | 463 if (!MediaStreamVideoSink::connected_track().isNull()) |
453 return; | 464 return; |
454 MediaStreamVideoSink::ConnectToTrack( | 465 MediaStreamVideoSink::ConnectToTrack( |
455 track_, media::BindToCurrentLoop( | 466 track_, media::BindToCurrentLoop( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 blink::WebMediaStreamSource webkit_source; | 526 blink::WebMediaStreamSource webkit_source; |
516 webkit_source.initialize(blink::WebString::fromASCII(source_id), | 527 webkit_source.initialize(blink::WebString::fromASCII(source_id), |
517 blink::WebMediaStreamSource::TypeVideo, | 528 blink::WebMediaStreamSource::TypeVideo, |
518 blink::WebString::fromASCII(kPepperVideoSourceName), | 529 blink::WebString::fromASCII(kPepperVideoSourceName), |
519 false /* remote */); | 530 false /* remote */); |
520 MediaStreamVideoSource* const source = | 531 MediaStreamVideoSource* const source = |
521 new VideoSource(weak_factory_.GetWeakPtr()); | 532 new VideoSource(weak_factory_.GetWeakPtr()); |
522 webkit_source.setExtraData(source); // Takes ownership of |source|. | 533 webkit_source.setExtraData(source); // Takes ownership of |source|. |
523 | 534 |
524 const bool enabled = true; | 535 const bool enabled = true; |
525 blink::WebMediaConstraints constraints; | |
526 constraints.initialize(); | |
527 track_ = MediaStreamVideoTrack::CreateVideoTrack( | 536 track_ = MediaStreamVideoTrack::CreateVideoTrack( |
528 source, constraints, | 537 source, |
529 base::Bind( | 538 base::Bind(&PepperMediaStreamVideoTrackHost::OnTrackStarted, |
530 &PepperMediaStreamVideoTrackHost::OnTrackStarted, | 539 base::Unretained(this)), |
531 base::Unretained(this)), | 540 enabled); |
532 enabled); | |
533 // Note: The call to CreateVideoTrack() returned a track that holds a | 541 // Note: The call to CreateVideoTrack() returned a track that holds a |
534 // ref-counted reference to |webkit_source| (and, implicitly, |source|). | 542 // ref-counted reference to |webkit_source| (and, implicitly, |source|). |
535 } | 543 } |
536 | 544 |
537 void PepperMediaStreamVideoTrackHost::OnTrackStarted( | 545 void PepperMediaStreamVideoTrackHost::OnTrackStarted( |
538 MediaStreamSource* source, | 546 MediaStreamSource* source, |
539 MediaStreamRequestResult result, | 547 MediaStreamRequestResult result, |
540 const blink::WebString& result_name) { | 548 const blink::WebString& result_name) { |
541 DVLOG(3) << "OnTrackStarted result: " << result; | 549 DVLOG(3) << "OnTrackStarted result: " << result; |
542 } | 550 } |
543 | 551 |
544 } // namespace content | 552 } // namespace content |
OLD | NEW |