OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/media/video_track_recorder.h" | 5 #include "content/renderer/media/video_track_recorder.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/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "ui/gfx/geometry/size.h" |
14 | 15 |
15 extern "C" { | 16 extern "C" { |
16 // VPX_CODEC_DISABLE_COMPAT excludes parts of the libvpx API that provide | 17 // VPX_CODEC_DISABLE_COMPAT excludes parts of the libvpx API that provide |
17 // backwards compatibility for legacy applications using the library. | 18 // backwards compatibility for legacy applications using the library. |
18 #define VPX_CODEC_DISABLE_COMPAT 1 | 19 #define VPX_CODEC_DISABLE_COMPAT 1 |
19 #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" | 20 #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" |
20 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" | 21 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" |
21 } | 22 } |
22 | 23 |
23 using media::VideoFrame; | 24 using media::VideoFrame; |
(...skipping 20 matching lines...) Expand all Loading... |
44 typedef scoped_ptr<vpx_codec_ctx_t, VpxCodecDeleter> ScopedVpxCodecCtxPtr; | 45 typedef scoped_ptr<vpx_codec_ctx_t, VpxCodecDeleter> ScopedVpxCodecCtxPtr; |
45 | 46 |
46 void OnFrameEncodeCompleted( | 47 void OnFrameEncodeCompleted( |
47 const VideoTrackRecorder::OnEncodedVideoCB& on_encoded_video_cb, | 48 const VideoTrackRecorder::OnEncodedVideoCB& on_encoded_video_cb, |
48 const scoped_refptr<VideoFrame>& frame, | 49 const scoped_refptr<VideoFrame>& frame, |
49 scoped_ptr<std::string> data, | 50 scoped_ptr<std::string> data, |
50 base::TimeTicks capture_timestamp, | 51 base::TimeTicks capture_timestamp, |
51 bool keyframe) { | 52 bool keyframe) { |
52 DVLOG(1) << (keyframe ? "" : "non ") << "keyframe "<< data->length() << "B, " | 53 DVLOG(1) << (keyframe ? "" : "non ") << "keyframe "<< data->length() << "B, " |
53 << capture_timestamp << " ms"; | 54 << capture_timestamp << " ms"; |
54 on_encoded_video_cb.Run(frame, base::StringPiece(*data), capture_timestamp, | 55 on_encoded_video_cb.Run(frame, data.Pass(), capture_timestamp, keyframe); |
55 keyframe); | |
56 } | 56 } |
57 | 57 |
58 } // anonymous namespace | 58 } // anonymous namespace |
59 | 59 |
60 // Inner class encapsulating all libvpx interactions and the encoding+delivery | 60 // Inner class encapsulating all libvpx interactions and the encoding+delivery |
61 // of received frames. Limitation: Only VP8 is supported for the time being. | 61 // of received frames. Limitation: Only VP8 is supported for the time being. |
62 // This class must be ref-counted because the MediaStreamVideoTrack will hold a | 62 // This class must be ref-counted because the MediaStreamVideoTrack will hold a |
63 // reference to it, via the callback MediaStreamVideoSink passes along, and it's | 63 // reference to it, via the callback MediaStreamVideoSink passes along, and it's |
64 // unknown when exactly it will release that reference. This class: | 64 // unknown when exactly it will release that reference. This class: |
65 // - is created and destroyed on its parent's thread (usually the main Render | 65 // - is created and destroyed on its parent's thread (usually the main Render |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 track_.reset(); | 339 track_.reset(); |
340 } | 340 } |
341 | 341 |
342 void VideoTrackRecorder::OnVideoFrameForTesting( | 342 void VideoTrackRecorder::OnVideoFrameForTesting( |
343 const scoped_refptr<media::VideoFrame>& frame, | 343 const scoped_refptr<media::VideoFrame>& frame, |
344 base::TimeTicks timestamp) { | 344 base::TimeTicks timestamp) { |
345 encoder_->StartFrameEncode(frame, timestamp); | 345 encoder_->StartFrameEncode(frame, timestamp); |
346 } | 346 } |
347 | 347 |
348 } // namespace content | 348 } // namespace content |
OLD | NEW |