OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_GPU_MEDIA_FOUNDATION_VIDEO_ENCODE_ACCELERATOR_WIN_H_ | 5 #ifndef MEDIA_GPU_MEDIA_FOUNDATION_VIDEO_ENCODE_ACCELERATOR_WIN_H_ |
6 #define MEDIA_GPU_MEDIA_FOUNDATION_VIDEO_ENCODE_ACCELERATOR_WIN_H_ | 6 #define MEDIA_GPU_MEDIA_FOUNDATION_VIDEO_ENCODE_ACCELERATOR_WIN_H_ |
7 | 7 |
8 #include <mfapi.h> | 8 #include <mfapi.h> |
9 #include <mfidl.h> | 9 #include <mfidl.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "base/threading/thread_checker.h" | 21 #include "base/threading/thread_checker.h" |
22 #include "base/win/scoped_comptr.h" | 22 #include "base/win/scoped_comptr.h" |
23 #include "media/gpu/media_gpu_export.h" | 23 #include "media/gpu/media_gpu_export.h" |
24 #include "media/video/video_encode_accelerator.h" | 24 #include "media/video/video_encode_accelerator.h" |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 | 27 |
28 // Media Foundation implementation of the VideoEncodeAccelerator interface for | 28 // Media Foundation implementation of the VideoEncodeAccelerator interface for |
29 // Windows. | 29 // Windows. |
30 // This class saves the task runner on which it is constructed and returns | 30 // This class saves the task runner on which it is constructed and returns |
31 // encoded data to the client using that same task runner. This class has | 31 // encoded data to the client using that same task runner. If |
32 // DCHECKs to makes sure that methods are called in sequence. It starts an | 32 // TryToSetupEncodeOnSeparateThread() is called, it use=s the given |
sandersd (OOO until July 31)
2016/10/21 01:01:00
Remove '='
emircan
2016/10/24 19:44:53
Done.
| |
33 // internal encoder thread on which VideoEncodeAccelerator implementation tasks | 33 // |encode_task_runner| instead. This class has DCHECKs to makes sure that |
34 // are posted. | 34 // methods are called in sequence. It starts an internal encoder thread on which |
35 // VideoEncodeAccelerator implementation tasks are posted. | |
35 class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator | 36 class MEDIA_GPU_EXPORT MediaFoundationVideoEncodeAccelerator |
36 : public VideoEncodeAccelerator { | 37 : public VideoEncodeAccelerator { |
37 public: | 38 public: |
38 MediaFoundationVideoEncodeAccelerator(); | 39 MediaFoundationVideoEncodeAccelerator(); |
39 | 40 |
40 // VideoEncodeAccelerator implementation. | 41 // VideoEncodeAccelerator implementation. |
41 VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() override; | 42 VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() override; |
42 bool Initialize(VideoPixelFormat input_format, | 43 bool Initialize(VideoPixelFormat input_format, |
43 const gfx::Size& input_visible_size, | 44 const gfx::Size& input_visible_size, |
44 VideoCodecProfile output_profile, | 45 VideoCodecProfile output_profile, |
45 uint32_t initial_bitrate, | 46 uint32_t initial_bitrate, |
46 Client* client) override; | 47 Client* client) override; |
47 void Encode(const scoped_refptr<VideoFrame>& frame, | 48 void Encode(const scoped_refptr<VideoFrame>& frame, |
48 bool force_keyframe) override; | 49 bool force_keyframe) override; |
49 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override; | 50 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override; |
50 void RequestEncodingParametersChange(uint32_t bitrate, | 51 void RequestEncodingParametersChange(uint32_t bitrate, |
51 uint32_t framerate) override; | 52 uint32_t framerate) override; |
52 void Destroy() override; | 53 void Destroy() override; |
54 bool TryToSetupEncodeOnSeparateThread( | |
55 const base::WeakPtr<Client>& encode_client, | |
56 const scoped_refptr<base::SingleThreadTaskRunner>& encode_task_runner) | |
57 override; | |
53 | 58 |
54 // Preload dlls required for encoding. | 59 // Preload dlls required for encoding. |
55 static void PreSandboxInitialization(); | 60 static void PreSandboxInitialization(); |
56 | 61 |
57 protected: | 62 protected: |
58 ~MediaFoundationVideoEncodeAccelerator() override; | 63 ~MediaFoundationVideoEncodeAccelerator() override; |
59 | 64 |
60 private: | 65 private: |
61 // Holds output buffers coming from the client ready to be filled. | 66 // Holds output buffers coming from the client ready to be filled. |
62 struct BitstreamBufferRef; | 67 struct BitstreamBufferRef; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 128 |
124 base::win::ScopedComPtr<IMFSample> input_sample_; | 129 base::win::ScopedComPtr<IMFSample> input_sample_; |
125 base::win::ScopedComPtr<IMFSample> output_sample_; | 130 base::win::ScopedComPtr<IMFSample> output_sample_; |
126 | 131 |
127 // To expose client callbacks from VideoEncodeAccelerator. | 132 // To expose client callbacks from VideoEncodeAccelerator. |
128 // NOTE: all calls to this object *MUST* be executed on |client_task_runner_|. | 133 // NOTE: all calls to this object *MUST* be executed on |client_task_runner_|. |
129 base::WeakPtr<Client> client_; | 134 base::WeakPtr<Client> client_; |
130 std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; | 135 std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; |
131 | 136 |
132 // Our original calling task runner for the child thread. | 137 // Our original calling task runner for the child thread. |
133 const scoped_refptr<base::SequencedTaskRunner> client_task_runner_; | 138 scoped_refptr<base::SequencedTaskRunner> client_task_runner_; |
134 // Sequence checker to enforce that the methods of this object are called in | 139 |
135 // sequence. | 140 // Thread checker to enforce that this object created, initialized and |
141 // destroyed on a specific thread. It is pinned on the thread where object is | |
142 // created. | |
143 base::ThreadChecker thread_checker_; | |
144 | |
145 // Sequence checker to enforce that the encode tasks of this object are called | |
146 // in sequence. | |
136 base::SequenceChecker sequence_checker_; | 147 base::SequenceChecker sequence_checker_; |
137 | 148 |
138 // This thread services tasks posted from the VEA API entry points by the | 149 // This thread services tasks posted from the VEA API entry points by the |
139 // GPU child thread and CompressionCallback() posted from device thread. | 150 // GPU child thread and CompressionCallback() posted from device thread. |
140 base::Thread encoder_thread_; | 151 base::Thread encoder_thread_; |
141 scoped_refptr<base::SingleThreadTaskRunner> encoder_thread_task_runner_; | 152 scoped_refptr<base::SingleThreadTaskRunner> encoder_thread_task_runner_; |
142 | 153 |
143 // Declared last to ensure that all weak pointers are invalidated before | 154 // Declared last to ensure that all weak pointers are invalidated before |
144 // other destructors run. | 155 // other destructors run. |
145 base::WeakPtrFactory<MediaFoundationVideoEncodeAccelerator> | 156 base::WeakPtrFactory<MediaFoundationVideoEncodeAccelerator> |
146 encoder_task_weak_factory_; | 157 encoder_task_weak_factory_; |
147 | 158 |
148 DISALLOW_COPY_AND_ASSIGN(MediaFoundationVideoEncodeAccelerator); | 159 DISALLOW_COPY_AND_ASSIGN(MediaFoundationVideoEncodeAccelerator); |
149 }; | 160 }; |
150 | 161 |
151 } // namespace media | 162 } // namespace media |
152 | 163 |
153 #endif // MEDIA_GPU_MEDIA_FOUNDATION_VIDEO_ENCODE_ACCELERATOR_WIN_H_ | 164 #endif // MEDIA_GPU_MEDIA_FOUNDATION_VIDEO_ENCODE_ACCELERATOR_WIN_H_ |
OLD | NEW |