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

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

Issue 1905763002: Convert //media/cast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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_VIDEO_ENCODER_H_ 5 #ifndef MEDIA_CAST_SENDER_VIDEO_ENCODER_H_
6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_H_ 6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_H_
7 7
8 #include <memory>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
13 #include "media/cast/cast_config.h" 14 #include "media/cast/cast_config.h"
14 #include "media/cast/cast_environment.h" 15 #include "media/cast/cast_environment.h"
15 #include "media/cast/cast_sender.h" 16 #include "media/cast/cast_sender.h"
16 #include "media/cast/sender/sender_encoded_frame.h" 17 #include "media/cast/sender/sender_encoded_frame.h"
17 #include "media/cast/sender/video_frame_factory.h" 18 #include "media/cast/sender/video_frame_factory.h"
18 19
19 namespace media { 20 namespace media {
20 namespace cast { 21 namespace cast {
21 22
22 // All these functions are called from the main cast thread. 23 // All these functions are called from the main cast thread.
23 class VideoEncoder { 24 class VideoEncoder {
24 public: 25 public:
25 // Callback used to deliver an encoded frame on the Cast MAIN thread. 26 // Callback used to deliver an encoded frame on the Cast MAIN thread.
26 using FrameEncodedCallback = 27 using FrameEncodedCallback =
27 base::Callback<void(scoped_ptr<SenderEncodedFrame>)>; 28 base::Callback<void(std::unique_ptr<SenderEncodedFrame>)>;
28 29
29 // Creates a VideoEncoder instance from the given |video_config| and based on 30 // Creates a VideoEncoder instance from the given |video_config| and based on
30 // the current platform's hardware/library support; or null if no 31 // the current platform's hardware/library support; or null if no
31 // implementation will suffice. The instance will run |status_change_cb| at 32 // implementation will suffice. The instance will run |status_change_cb| at
32 // some point in the future to indicate initialization success/failure. 33 // some point in the future to indicate initialization success/failure.
33 // 34 //
34 // All VideoEncoder instances returned by this function support encoding 35 // All VideoEncoder instances returned by this function support encoding
35 // sequences of differently-size VideoFrames. 36 // sequences of differently-size VideoFrames.
36 // 37 //
37 // TODO(miu): Remove the CreateVEA callbacks. http://crbug.com/454029 38 // TODO(miu): Remove the CreateVEA callbacks. http://crbug.com/454029
38 static scoped_ptr<VideoEncoder> Create( 39 static std::unique_ptr<VideoEncoder> Create(
39 const scoped_refptr<CastEnvironment>& cast_environment, 40 const scoped_refptr<CastEnvironment>& cast_environment,
40 const VideoSenderConfig& video_config, 41 const VideoSenderConfig& video_config,
41 const StatusChangeCallback& status_change_cb, 42 const StatusChangeCallback& status_change_cb,
42 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, 43 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
43 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb); 44 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb);
44 45
45 virtual ~VideoEncoder() {} 46 virtual ~VideoEncoder() {}
46 47
47 // If true is returned, the Encoder has accepted the request and will process 48 // If true is returned, the Encoder has accepted the request and will process
48 // it asynchronously, running |frame_encoded_callback| on the MAIN 49 // it asynchronously, running |frame_encoded_callback| on the MAIN
49 // CastEnvironment thread with the result. If false is returned, nothing 50 // CastEnvironment thread with the result. If false is returned, nothing
50 // happens and the callback will not be run. 51 // happens and the callback will not be run.
51 virtual bool EncodeVideoFrame( 52 virtual bool EncodeVideoFrame(
52 const scoped_refptr<media::VideoFrame>& video_frame, 53 const scoped_refptr<media::VideoFrame>& video_frame,
53 const base::TimeTicks& reference_time, 54 const base::TimeTicks& reference_time,
54 const FrameEncodedCallback& frame_encoded_callback) = 0; 55 const FrameEncodedCallback& frame_encoded_callback) = 0;
55 56
56 // Inform the encoder about the new target bit rate. 57 // Inform the encoder about the new target bit rate.
57 virtual void SetBitRate(int new_bit_rate) = 0; 58 virtual void SetBitRate(int new_bit_rate) = 0;
58 59
59 // Inform the encoder to encode the next frame as a key frame. 60 // Inform the encoder to encode the next frame as a key frame.
60 virtual void GenerateKeyFrame() = 0; 61 virtual void GenerateKeyFrame() = 0;
61 62
62 // Creates a |VideoFrameFactory| object to vend |VideoFrame| object with 63 // Creates a |VideoFrameFactory| object to vend |VideoFrame| object with
63 // encoder affinity (defined as offering some sort of performance benefit). 64 // encoder affinity (defined as offering some sort of performance benefit).
64 // This is an optional capability and by default returns null. 65 // This is an optional capability and by default returns null.
65 virtual scoped_ptr<VideoFrameFactory> CreateVideoFrameFactory(); 66 virtual std::unique_ptr<VideoFrameFactory> CreateVideoFrameFactory();
66 67
67 // Instructs the encoder to finish and emit all frames that have been 68 // Instructs the encoder to finish and emit all frames that have been
68 // submitted for encoding. An encoder may hold a certain number of frames for 69 // submitted for encoding. An encoder may hold a certain number of frames for
69 // analysis. Under certain network conditions, particularly when there is 70 // analysis. Under certain network conditions, particularly when there is
70 // network congestion, it is necessary to flush out of the encoder all 71 // network congestion, it is necessary to flush out of the encoder all
71 // submitted frames so that eventually new frames may be encoded. Like 72 // submitted frames so that eventually new frames may be encoded. Like
72 // EncodeVideoFrame(), the encoder will process this request asynchronously. 73 // EncodeVideoFrame(), the encoder will process this request asynchronously.
73 virtual void EmitFrames(); 74 virtual void EmitFrames();
74 }; 75 };
75 76
76 } // namespace cast 77 } // namespace cast
77 } // namespace media 78 } // namespace media
78 79
79 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_H_ 80 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « media/cast/sender/size_adaptable_video_encoder_base.cc ('k') | media/cast/sender/video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698