| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_TOOLS_OMX_TEST_FILE_SINK_H_ | 5 #ifndef MEDIA_TOOLS_OMX_TEST_FILE_SINK_H_ |
| 6 #define MEDIA_TOOLS_OMX_TEST_FILE_SINK_H_ | 6 #define MEDIA_TOOLS_OMX_TEST_FILE_SINK_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/scoped_handle.h" | 12 #include "base/scoped_handle.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "media/omx/omx_output_sink.h" | |
| 15 | 14 |
| 16 namespace media { | 15 namespace media { |
| 17 | 16 |
| 18 // This class writes output of a frame decoded by OmxCodec and save it to | 17 // This class writes output of a frame decoded by OmxCodec and save it to |
| 19 // a file. | 18 // a file. |
| 20 class FileSink : public OmxOutputSink { | 19 class FileSink { |
| 21 public: | 20 public: |
| 22 FileSink(std::string output_filename, | 21 FileSink(std::string output_filename, |
| 23 bool simulate_copy, | 22 bool simulate_copy, |
| 24 bool enable_csc) | 23 bool enable_csc) |
| 25 : output_filename_(output_filename), | 24 : output_filename_(output_filename), |
| 26 simulate_copy_(simulate_copy), | 25 simulate_copy_(simulate_copy), |
| 27 enable_csc_(enable_csc), | 26 enable_csc_(enable_csc), |
| 28 width_(0), | 27 width_(0), |
| 29 height_(0), | 28 height_(0), |
| 30 copy_buf_size_(0), | 29 copy_buf_size_(0), |
| 31 csc_buf_size_(0) { | 30 csc_buf_size_(0) { |
| 32 } | 31 } |
| 33 | 32 |
| 34 // OmxOutputSink implementations. | 33 virtual void BufferReady(int size, uint8* buffer); |
| 35 virtual bool ProvidesEGLImages() const { return false; } | |
| 36 virtual bool AllocateEGLImages(int width, int height, | |
| 37 std::vector<EGLImageKHR>* images); | |
| 38 virtual void ReleaseEGLImages(const std::vector<EGLImageKHR>& images); | |
| 39 virtual void UseThisBuffer(int buffer_id, OMX_BUFFERHEADERTYPE* buffer); | |
| 40 virtual void StopUsingThisBuffer(int id); | |
| 41 virtual void BufferReady(int buffer_id, BufferUsedCallback* callback); | |
| 42 | 34 |
| 43 // Initialize this object. Returns true if successful. | 35 // Initialize this object. Returns true if successful. |
| 44 bool Initialize(); | 36 bool Initialize(); |
| 45 | 37 |
| 46 // Update the output frame size. | 38 // Update the output frame size. |
| 47 void UpdateSize(int wdith, int height); | 39 void UpdateSize(int wdith, int height); |
| 48 | 40 |
| 49 // Write the frame buffer reference by |buffer|. | 41 // Write the frame buffer reference by |buffer|. |
| 50 void Write(uint8* buffer, int size); | 42 void Write(uint8* buffer, int size); |
| 51 | 43 |
| 52 private: | 44 private: |
| 53 std::string output_filename_; | 45 std::string output_filename_; |
| 54 bool simulate_copy_; | 46 bool simulate_copy_; |
| 55 bool enable_csc_; | 47 bool enable_csc_; |
| 56 ScopedStdioHandle output_file_; | 48 ScopedStdioHandle output_file_; |
| 57 | 49 |
| 58 // Image properties. | 50 // Image properties. |
| 59 int width_; | 51 int width_; |
| 60 int height_; | 52 int height_; |
| 61 | 53 |
| 62 // Buffers for copying and color space conversion. | 54 // Buffers for copying and color space conversion. |
| 63 scoped_array<uint8> copy_buf_; | 55 scoped_array<uint8> copy_buf_; |
| 64 int copy_buf_size_; | 56 int copy_buf_size_; |
| 65 scoped_array<uint8> csc_buf_; | 57 scoped_array<uint8> csc_buf_; |
| 66 int csc_buf_size_; | 58 int csc_buf_size_; |
| 67 | 59 |
| 68 std::map<int, OMX_BUFFERHEADERTYPE*> omx_buffers_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(FileSink); | 60 DISALLOW_COPY_AND_ASSIGN(FileSink); |
| 71 }; | 61 }; |
| 72 | 62 |
| 73 } // namespace media | 63 } // namespace media |
| 74 | 64 |
| 75 #endif // MEDIA_TOOLS_OMX_TEST_FILE_SINK_H_ | 65 #endif // MEDIA_TOOLS_OMX_TEST_FILE_SINK_H_ |
| OLD | NEW |