Chromium Code Reviews| Index: content/renderer/media/video_track_recorder.h |
| diff --git a/content/renderer/media/video_track_recorder.h b/content/renderer/media/video_track_recorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..97cd8b8a31e93a55828db943d07f137e00097e8e |
| --- /dev/null |
| +++ b/content/renderer/media/video_track_recorder.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |
| +#define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/strings/string_piece.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "content/public/renderer/media_stream_video_sink.h" |
| +#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| +#include "ui/gfx/geometry/size.h" |
| + |
| +namespace content { |
| + |
| +// VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames |
| +// received from a Stream Video Track. The class is constructed and used on a |
| +// single thread, namely the main Render thread. It has an internal VpxEncoder |
| +// living on Render IO thread and using an encoding thread. |
|
miu
2015/07/27 22:30:09
1. This should not be done on the IO thread.
2. I
mcasas
2015/07/31 11:26:27
What I meant is that callbacks to the "internal Vp
|
| +class CONTENT_EXPORT VideoTrackRecorder |
| + : NON_EXPORTED_BASE(public MediaStreamVideoSink) { |
| + public: |
| + using OnFirstFrameCB = base::Callback<uint64_t(const gfx::Size& frame_size, |
| + double frame_rate)>; |
| + |
| + using OnEncodedVideoCB = base::Callback<void(uint64_t track_number, |
|
miu
2015/07/27 22:30:09
|track_number| does not belong in this API nor thi
mcasas
2015/07/31 11:26:27
I'm not sure I understand. Do you mean OnFirstFram
miu
2015/08/04 04:06:30
Sorry. I wasn't very clear here. Basically, I th
mcasas
2015/08/11 09:35:17
I agree that the |track_index| should not be surfa
|
| + const base::StringPiece& data, |
| + base::TimeDelta timestamp, |
| + bool keyframe)>; |
| + |
| + VideoTrackRecorder( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| + const blink::WebMediaStreamTrack& track, |
| + const OnFirstFrameCB& on_first_frame_cb, |
| + const OnEncodedVideoCB& on_encoded_video_cb); |
| + ~VideoTrackRecorder() override; |
| + |
| + private: |
| + friend class VideoTrackRecorderTest; |
| + |
| + // Used to ping |encoder_->EncodeOnIo()| for testing. |
| + void EncodeOnIoForTesting(const scoped_refptr<media::VideoFrame>& frame, |
| + const base::TimeTicks& estimated_capture_time); |
| + |
| + // Used to check that we are destroyed on the same thread we were created. |
| + base::ThreadChecker main_render_thread_checker_; |
| + |
| + // We need to hold on to the Blink track to remove ourselves on dtor. |
| + const blink::WebMediaStreamTrack track_; |
| + |
| + // Forward declaration and member of an inner class to encode using VPx. |
| + class VpxEncoder; |
| + const scoped_refptr<VpxEncoder> encoder_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); |
| +}; |
| + |
| +} // namespace content |
| +#endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |