| 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..66d347ffb1c21640e00939f8be98d82b7920b5d3 | 
| --- /dev/null | 
| +++ b/content/renderer/media/video_track_recorder.h | 
| @@ -0,0 +1,62 @@ | 
| +// 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/memory/weak_ptr.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 media { | 
| +class VideoFrame; | 
| +}  // namespace media | 
| + | 
| +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 | 
| +// that uses a worker thread for encoding. | 
| +class CONTENT_EXPORT VideoTrackRecorder | 
| +    : NON_EXPORTED_BASE(public MediaStreamVideoSink) { | 
| + public: | 
| +  using OnEncodedVideoCB = | 
| +      base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, | 
| +                          const base::StringPiece& encoded_data, | 
| +                          base::TimeTicks capture_timestamp, | 
| +                          bool is_key_frame)>; | 
| + | 
| +  VideoTrackRecorder(const blink::WebMediaStreamTrack& track, | 
| +                     const OnEncodedVideoCB& on_encoded_video_cb); | 
| +  ~VideoTrackRecorder() override; | 
| + | 
| +  void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame, | 
| +                    const base::TimeTicks& capture_time); | 
| + | 
| + private: | 
| +  friend class VideoTrackRecorderTest; | 
| + | 
| +  // 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. | 
| +  blink::WebMediaStreamTrack track_; | 
| + | 
| +  // Forward declaration and member of an inner class to encode using VPx. | 
| +  class VpxEncoder; | 
| +  const scoped_ptr<VpxEncoder> encoder_; | 
| + | 
| +  base::WeakPtrFactory<VideoTrackRecorder> weak_factory_; | 
| + | 
| +  DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | 
| +}; | 
| + | 
| +}  // namespace content | 
| +#endif  // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | 
|  |