OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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_VIDEO_VIDEO_DECODE_CONTEXT_H_ | |
6 #define MEDIA_VIDEO_VIDEO_DECODE_CONTEXT_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/task.h" | |
11 #include "media/base/video_frame.h" | |
12 | |
13 namespace media { | |
14 | |
15 class VideoFrame; | |
16 | |
17 // A VideoDecodeContext is used by VideoDecodeEngine to provide the following | |
18 // functions: | |
19 // | |
20 // 1. Provides access to hardware video decoding device. | |
21 // 2. Allocate VideoFrame objects that are used to carry the decoded video | |
22 // frames. | |
23 // 3. Upload a device specific buffer to some common VideoFrame storage types. | |
24 // In many cases a VideoDecodeEngine provides its own buffer, these buffer | |
25 // are usually device specific and a conversion step is needed. Instead of | |
26 // handling these many cases in the renderer a VideoDecodeContext is used | |
27 // to convert the device specific buffer to a common storage format, e.g. | |
28 // GL textures or system memory. This way we keep the device specific code | |
29 // in the VideoDecodeEngine and VideoDecodeContext pair. | |
30 class VideoDecodeContext { | |
31 public: | |
32 virtual ~VideoDecodeContext() {} | |
33 | |
34 // Obtain a handle to the hardware video decoder device. The type of the | |
35 // handle is a contract between the implementation of VideoDecodeContext and | |
36 // VideoDecodeEngine. | |
37 // | |
38 // If a hardware device is not needed this method should return NULL. | |
39 virtual void* GetDevice() = 0; | |
40 | |
41 // Allocate |n| video frames with dimension |width| and |height|. |task| | |
42 // is called when allocation has completed. | |
43 // | |
44 // |frames| is the output parameter for VideFrame(s) allocated. | |
45 virtual void AllocateVideoFrames( | |
46 int n, size_t width, size_t height, VideoFrame::Format format, | |
47 std::vector<scoped_refptr<VideoFrame> >* frames, | |
48 Task* task) = 0; | |
49 | |
50 // Release all video frames allocated by the context. After making this call | |
51 // VideoDecodeEngine should not use the VideoFrame allocated because they | |
52 // could be destroyed. | |
53 virtual void ReleaseAllVideoFrames() = 0; | |
54 | |
55 // Upload a device specific buffer to a video frame. The video frame was | |
56 // allocated via AllocateVideoFrames(). | |
57 // This method is used if a VideoDecodeEngine cannot write directly to a | |
58 // VideoFrame, e.g. upload should be done on a different thread, the subsystem | |
59 // require some special treatment to generate a VideoFrame. The goal is to | |
60 // keep VideoDecodeEngine a reusable component and also adapt to different | |
61 // system by having a different VideoDecodeContext. | |
62 // | |
63 // |frame| is a VideoFrame allocated via AllocateVideoFrames(). | |
64 // | |
65 // |buffer| is of type void*, it is of an internal type in VideoDecodeEngine | |
66 // that points to the buffer that contains the video frame. | |
67 // Implementor should know how to handle it. | |
68 // | |
69 // |task| is executed if the operation was completed successfully. | |
70 virtual void ConvertToVideoFrame(void* buffer, | |
71 scoped_refptr<VideoFrame> frame, | |
72 Task* task) = 0; | |
73 | |
74 // Destroy this context asynchronously. When the operation is done |task| | |
75 // is called. It is safe to delete this object only after |task| is called. | |
76 // | |
77 // ReleaseVideoFrames() need to be called with all the video frames allocated | |
78 // before making this call. | |
79 virtual void Destroy(Task* task) = 0; | |
80 }; | |
81 | |
82 } // namespace media | |
83 | |
84 #endif // MEDIA_VIDEO_VIDEO_DECODE_CONTEXT_H_ | |
OLD | NEW |