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

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

Issue 906403006: [Cast] Size-Adaptable platform video encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed hubbe's comments. Created 5 years, 10 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
« no previous file with comments | « media/cast/cast_testing.gypi ('k') | media/cast/sender/external_video_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SENDER_EXTERNAL_VIDEO_ENCODER_H_ 5 #ifndef MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_
6 #define MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ 6 #define MEDIA_CAST_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/sender/size_adaptable_video_encoder_base.h"
12 #include "media/cast/sender/video_encoder.h" 13 #include "media/cast/sender/video_encoder.h"
13 #include "media/video/video_encode_accelerator.h" 14 #include "media/video/video_encode_accelerator.h"
14 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
15 16
16 namespace media { 17 namespace media {
17 namespace cast { 18 namespace cast {
18 19
19 // Cast MAIN thread proxy to the internal media::VideoEncodeAccelerator 20 // Cast MAIN thread proxy to the internal media::VideoEncodeAccelerator
20 // implementation running on a separate thread. Encodes media::VideoFrames and 21 // implementation running on a separate thread. Encodes media::VideoFrames and
21 // emits media::cast::EncodedFrames. 22 // emits media::cast::EncodedFrames.
22 class ExternalVideoEncoder : public VideoEncoder { 23 class ExternalVideoEncoder : public VideoEncoder {
23 public: 24 public:
25 // Returns true if the current platform and system configuration supports
26 // using ExternalVideoEncoder with the given |video_config|.
27 static bool IsSupported(const VideoSenderConfig& video_config);
28
24 ExternalVideoEncoder( 29 ExternalVideoEncoder(
25 const scoped_refptr<CastEnvironment>& cast_environment, 30 const scoped_refptr<CastEnvironment>& cast_environment,
26 const VideoSenderConfig& video_config, 31 const VideoSenderConfig& video_config,
27 const gfx::Size& frame_size, 32 const gfx::Size& frame_size,
33 uint32 first_frame_id,
28 const StatusChangeCallback& status_change_cb, 34 const StatusChangeCallback& status_change_cb,
29 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, 35 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
30 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb); 36 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb);
31 37
32 ~ExternalVideoEncoder() override; 38 ~ExternalVideoEncoder() override;
33 39
34 // VideoEncoder implementation. 40 // VideoEncoder implementation.
35 bool CanEncodeVariedFrameSizes() const override;
36 bool EncodeVideoFrame( 41 bool EncodeVideoFrame(
37 const scoped_refptr<media::VideoFrame>& video_frame, 42 const scoped_refptr<media::VideoFrame>& video_frame,
38 const base::TimeTicks& reference_time, 43 const base::TimeTicks& reference_time,
39 const FrameEncodedCallback& frame_encoded_callback) override; 44 const FrameEncodedCallback& frame_encoded_callback) override;
40 void SetBitRate(int new_bit_rate) override; 45 void SetBitRate(int new_bit_rate) override;
41 void GenerateKeyFrame() override; 46 void GenerateKeyFrame() override;
42 void LatestFrameIdToReference(uint32 frame_id) override; 47 void LatestFrameIdToReference(uint32 frame_id) override;
43 48
44 private: 49 private:
45 class VEAClientImpl; 50 class VEAClientImpl;
46 51
47 // Method invoked by the CreateVideoEncodeAcceleratorCallback to construct a 52 // Method invoked by the CreateVideoEncodeAcceleratorCallback to construct a
48 // VEAClientImpl to own and interface with a new |vea|. Upon return, 53 // VEAClientImpl to own and interface with a new |vea|. Upon return,
49 // |client_| holds a reference to the new VEAClientImpl. 54 // |client_| holds a reference to the new VEAClientImpl.
50 void OnCreateVideoEncodeAccelerator( 55 void OnCreateVideoEncodeAccelerator(
51 const gfx::Size& frame_size, 56 const VideoSenderConfig& video_config,
52 VideoCodecProfile codec_profile, 57 uint32 first_frame_id,
53 int max_frame_rate,
54 const StatusChangeCallback& status_change_cb, 58 const StatusChangeCallback& status_change_cb,
55 scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner, 59 scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner,
56 scoped_ptr<media::VideoEncodeAccelerator> vea); 60 scoped_ptr<media::VideoEncodeAccelerator> vea);
57 61
58 const scoped_refptr<CastEnvironment> cast_environment_; 62 const scoped_refptr<CastEnvironment> cast_environment_;
59 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_; 63 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_;
64
65 // The size of the visible region of the video frames to be encoded.
66 const gfx::Size frame_size_;
67
60 int bit_rate_; 68 int bit_rate_;
61 bool key_frame_requested_; 69 bool key_frame_requested_;
62 70
63 scoped_refptr<VEAClientImpl> client_; 71 scoped_refptr<VEAClientImpl> client_;
64 72
65 // Provides a weak pointer for the OnCreateVideoEncoderAccelerator() callback. 73 // Provides a weak pointer for the OnCreateVideoEncoderAccelerator() callback.
66 // NOTE: Weak pointers must be invalidated before all other member variables. 74 // NOTE: Weak pointers must be invalidated before all other member variables.
67 base::WeakPtrFactory<ExternalVideoEncoder> weak_factory_; 75 base::WeakPtrFactory<ExternalVideoEncoder> weak_factory_;
68 76
69 DISALLOW_COPY_AND_ASSIGN(ExternalVideoEncoder); 77 DISALLOW_COPY_AND_ASSIGN(ExternalVideoEncoder);
70 }; 78 };
71 79
80 // An implementation of SizeAdaptableVideoEncoderBase to proxy for
81 // ExternalVideoEncoder instances.
82 class SizeAdaptableExternalVideoEncoder : public SizeAdaptableVideoEncoderBase {
83 public:
84 SizeAdaptableExternalVideoEncoder(
85 const scoped_refptr<CastEnvironment>& cast_environment,
86 const VideoSenderConfig& video_config,
87 const StatusChangeCallback& status_change_cb,
88 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
89 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb);
90
91 ~SizeAdaptableExternalVideoEncoder() override;
92
93 protected:
94 scoped_ptr<VideoEncoder> CreateEncoder() override;
95
96 private:
97 // Special callbacks needed by media::cast::ExternalVideoEncoder.
98 // TODO(miu): Remove these. http://crbug.com/454029
99 const CreateVideoEncodeAcceleratorCallback create_vea_cb_;
100 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_;
101
102 DISALLOW_COPY_AND_ASSIGN(SizeAdaptableExternalVideoEncoder);
103 };
104
72 } // namespace cast 105 } // namespace cast
73 } // namespace media 106 } // namespace media
74 107
75 #endif // MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ 108 #endif // MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « media/cast/cast_testing.gypi ('k') | media/cast/sender/external_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698