Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: media/cast/video_sender/external_video_encoder.h

Issue 207593002: Cast: Enable use of VideoEncodeAccelerator for hardware video encoding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typedef Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_ 5 #ifndef MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_
6 #define MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_ 6 #define MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "media/cast/cast_config.h" 10 #include "media/cast/cast_config.h"
11 #include "media/cast/cast_environment.h" 11 #include "media/cast/cast_environment.h"
12 #include "media/cast/video_sender/video_encoder.h" 12 #include "media/cast/video_sender/video_encoder.h"
13 #include "media/filters/gpu_video_accelerator_factories.h" 13 #include "media/video/video_encode_accelerator.h"
14 14
15 namespace media { 15 namespace media {
16 class VideoFrame; 16 class VideoFrame;
17 } 17 }
18 18
19 namespace media { 19 namespace media {
20 namespace cast { 20 namespace cast {
21 21
22 class LocalVideoEncodeAcceleratorClient; 22 class LocalVideoEncodeAcceleratorClient;
23 23
24 // This object is called external from the main cast thread and internally from 24 // This object is called external from the main cast thread and internally from
25 // the video encoder thread. 25 // the video encoder thread.
26 class ExternalVideoEncoder : public VideoEncoder { 26 class ExternalVideoEncoder : public VideoEncoder {
27 public: 27 public:
28 ExternalVideoEncoder( 28 ExternalVideoEncoder(
29 scoped_refptr<CastEnvironment> cast_environment, 29 scoped_refptr<CastEnvironment> cast_environment,
30 const VideoSenderConfig& video_config, 30 const VideoSenderConfig& video_config,
31 scoped_refptr<GpuVideoAcceleratorFactories> gpu_factories); 31 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
32 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb);
32 33
33 virtual ~ExternalVideoEncoder(); 34 virtual ~ExternalVideoEncoder();
34 35
35 // Called from the main cast thread. This function post the encode task to the 36 // Called from the main cast thread. This function post the encode task to the
36 // video encoder thread; 37 // video encoder thread;
37 // The video_frame must be valid until the closure callback is called. 38 // The video_frame must be valid until the closure callback is called.
38 // The closure callback is called from the video encoder thread as soon as 39 // The closure callback is called from the video encoder thread as soon as
39 // the encoder is done with the frame; it does not mean that the encoded frame 40 // the encoder is done with the frame; it does not mean that the encoded frame
40 // has been sent out. 41 // has been sent out.
41 // Once the encoded frame is ready the frame_encoded_callback is called. 42 // Once the encoded frame is ready the frame_encoded_callback is called.
42 virtual bool EncodeVideoFrame( 43 virtual bool EncodeVideoFrame(
43 const scoped_refptr<media::VideoFrame>& video_frame, 44 const scoped_refptr<media::VideoFrame>& video_frame,
44 const base::TimeTicks& capture_time, 45 const base::TimeTicks& capture_time,
45 const FrameEncodedCallback& frame_encoded_callback) OVERRIDE; 46 const FrameEncodedCallback& frame_encoded_callback) OVERRIDE;
46 47
47 // The following functions are called from the main cast thread. 48 // The following functions are called from the main cast thread.
48 virtual void SetBitRate(int new_bit_rate) OVERRIDE; 49 virtual void SetBitRate(int new_bit_rate) OVERRIDE;
49 virtual void SkipNextFrame(bool skip_next_frame) OVERRIDE; 50 virtual void SkipNextFrame(bool skip_next_frame) OVERRIDE;
50 virtual void GenerateKeyFrame() OVERRIDE; 51 virtual void GenerateKeyFrame() OVERRIDE;
51 virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE; 52 virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE;
52 virtual int NumberOfSkippedFrames() const OVERRIDE; 53 virtual int NumberOfSkippedFrames() const OVERRIDE;
53 54
55 // Called when a VEA is created.
56 void OnCreateVideoEncodeAccelerator(
57 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb,
58 scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner,
59 scoped_ptr<media::VideoEncodeAccelerator> vea);
60
54 protected: 61 protected:
55 void EncoderInitialized(); 62 void EncoderInitialized();
56 void EncoderError(); 63 void EncoderError();
57 64
58 private: 65 private:
59 friend class LocalVideoEncodeAcceleratorClient; 66 friend class LocalVideoEncodeAcceleratorClient;
60 67
61 const VideoSenderConfig video_config_; 68 const VideoSenderConfig video_config_;
62 scoped_refptr<CastEnvironment> cast_environment_; 69 scoped_refptr<CastEnvironment> cast_environment_;
63 70
(...skipping 10 matching lines...) Expand all
74 // NOTE: Weak pointers must be invalidated before all other member variables. 81 // NOTE: Weak pointers must be invalidated before all other member variables.
75 base::WeakPtrFactory<ExternalVideoEncoder> weak_factory_; 82 base::WeakPtrFactory<ExternalVideoEncoder> weak_factory_;
76 83
77 DISALLOW_COPY_AND_ASSIGN(ExternalVideoEncoder); 84 DISALLOW_COPY_AND_ASSIGN(ExternalVideoEncoder);
78 }; 85 };
79 86
80 } // namespace cast 87 } // namespace cast
81 } // namespace media 88 } // namespace media
82 89
83 #endif // MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_ 90 #endif // MEDIA_CAST_VIDEO_SENDER_EXTERNAL_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « media/cast/test/utility/default_config.cc ('k') | media/cast/video_sender/external_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698