Revert "Add sbox tests related to warming up of locales."
[chromium-blink-merge.git] / content / renderer / media / video_track_recorder.h
blob99a6acbd17770d0772f68fd0e46b8b03ddfda004
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string_piece.h"
12 #include "base/threading/thread_checker.h"
13 #include "content/public/renderer/media_stream_video_sink.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
15 #include "ui/gfx/geometry/size.h"
17 namespace media {
18 class VideoFrame;
19 } // namespace media
21 namespace content {
23 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames
24 // received from a Stream Video Track. The class is constructed and used on a
25 // single thread, namely the main Render thread. It has an internal VpxEncoder
26 // that uses a worker thread for encoding.
27 class CONTENT_EXPORT VideoTrackRecorder
28 : NON_EXPORTED_BASE(public MediaStreamVideoSink) {
29 public:
30 using OnEncodedVideoCB =
31 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame,
32 const base::StringPiece& encoded_data,
33 base::TimeTicks capture_timestamp,
34 bool is_key_frame)>;
36 VideoTrackRecorder(const blink::WebMediaStreamTrack& track,
37 const OnEncodedVideoCB& on_encoded_video_cb);
38 ~VideoTrackRecorder() override;
40 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame,
41 base::TimeTicks capture_time);
43 private:
44 friend class VideoTrackRecorderTest;
46 // Used to check that we are destroyed on the same thread we were created.
47 base::ThreadChecker main_render_thread_checker_;
49 // We need to hold on to the Blink track to remove ourselves on dtor.
50 blink::WebMediaStreamTrack track_;
52 // Forward declaration and member of an inner class to encode using VPx.
53 class VpxEncoder;
54 const scoped_ptr<VpxEncoder> encoder_;
56 base::WeakPtrFactory<VideoTrackRecorder> weak_factory_;
58 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
61 } // namespace content
62 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_