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

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

Issue 868803007: [Cast] Refactor ExternalVideoEncoder for cleaner/simpler encapsulation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add clarification comments and TODOs. 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAST_SENDER_FAKE_VIDEO_ENCODE_ACCELERATOR_FACTORY_H_
6 #define MEDIA_CAST_SENDER_FAKE_VIDEO_ENCODE_ACCELERATOR_FACTORY_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/shared_memory.h"
12 #include "base/single_thread_task_runner.h"
13 #include "media/cast/cast_config.h"
14 #include "media/video/fake_video_encode_accelerator.h"
15
16 namespace media {
17 namespace cast {
18
19 // Used by test code to create fake VideoEncodeAccelerators. The test code
20 // controls when the response callback is invoked.
21 class FakeVideoEncodeAcceleratorFactory {
22 public:
23 explicit FakeVideoEncodeAcceleratorFactory(
24 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
25 ~FakeVideoEncodeAcceleratorFactory();
26
27 int vea_response_count() const {
28 return vea_response_count_;
29 }
30 int shm_response_count() const {
31 return shm_response_count_;
32 }
33
34 // These return the instance last responded. It is up to the caller to
35 // determine whether the pointer is still valid, since this factory does not
36 // own these objects anymore.
37 media::FakeVideoEncodeAccelerator* last_response_vea() const {
38 return static_cast<media::FakeVideoEncodeAccelerator*>(last_response_vea_);
39 }
40 base::SharedMemory* last_response_shm() const {
41 return last_response_shm_;
42 }
43
44 // Set whether the next created media::FakeVideoEncodeAccelerator will
45 // initialize successfully.
46 void SetInitializationWillSucceed(bool will_init_succeed);
47
48 // Enable/disable auto-respond mode. Default is disabled.
49 void SetAutoRespond(bool auto_respond);
50
51 // Creates a media::FakeVideoEncodeAccelerator. If in auto-respond mode,
52 // |callback| is run synchronously (i.e., before this method returns).
53 void CreateVideoEncodeAccelerator(
54 const ReceiveVideoEncodeAcceleratorCallback& callback);
55
56 // Creates shared memory of the requested |size|. If in auto-respond mode,
57 // |callback| is run synchronously (i.e., before this method returns).
58 void CreateSharedMemory(
59 size_t size,
60 const ReceiveVideoEncodeMemoryCallback& callback);
61
62 // Runs the |callback| provided to the last call to
63 // CreateVideoEncodeAccelerator() with the new VideoEncodeAccelerator
64 // instance.
65 void RespondWithVideoEncodeAccelerator();
66
67 // Runs the |callback| provided to the last call to
68 // CreateSharedMemory() with the new base::SharedMemory instance.
69 void RespondWithSharedMemory();
70
71 private:
72 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
73 bool will_init_succeed_;
74 bool auto_respond_;
75 scoped_ptr<media::VideoEncodeAccelerator> next_response_vea_;
76 ReceiveVideoEncodeAcceleratorCallback vea_response_callback_;
77 scoped_ptr<base::SharedMemory> next_response_shm_;
78 ReceiveVideoEncodeMemoryCallback shm_response_callback_;
79 int vea_response_count_;
80 int shm_response_count_;
81 media::VideoEncodeAccelerator* last_response_vea_;
82 base::SharedMemory* last_response_shm_;
83
84 DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAcceleratorFactory);
85 };
86
87 } // namespace cast
88 } // namespace media
89
90 #endif // MEDIA_CAST_SENDER_FAKE_VIDEO_ENCODE_ACCELERATOR_FACTORY_H_
OLDNEW
« no previous file with comments | « media/cast/sender/external_video_encoder_unittest.cc ('k') | media/cast/sender/fake_video_encode_accelerator_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698