summaryrefslogtreecommitdiffstats
path: root/media/mf/file_reader_util.h
diff options
context:
space:
mode:
authorimcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 23:14:36 +0000
committerimcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 23:14:36 +0000
commit9c17999887073e5d0c58bd9e27ce56fd378a0e01 (patch)
tree55a82a7a64c0c8af96cd077164d5e000ddfb16ca /media/mf/file_reader_util.h
parenta5c493b9b38dcb17d5e621e06a9c9bb9e317c2f9 (diff)
downloadchromium_src-9c17999887073e5d0c58bd9e27ce56fd378a0e01.zip
chromium_src-9c17999887073e5d0c58bd9e27ce56fd378a0e01.tar.gz
chromium_src-9c17999887073e5d0c58bd9e27ce56fd378a0e01.tar.bz2
Moved files from media/media_foundation to media/mf. Cleaned up the code a little bit.
BUG=none TEST=coming Review URL: http://codereview.chromium.org/3072030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/mf/file_reader_util.h')
-rw-r--r--media/mf/file_reader_util.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/media/mf/file_reader_util.h b/media/mf/file_reader_util.h
new file mode 100644
index 0000000..a1426e0
--- /dev/null
+++ b/media/mf/file_reader_util.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Borrowed from media/tools/omx_test/file_reader_util.h.
+// Added some functionalities related to timestamps on packets and Media
+// Foundation.
+
+#ifndef MEDIA_MF_FILE_READER_UTIL_H_
+#define MEDIA_MF_FILE_READER_UTIL_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/scoped_handle.h"
+#include "base/scoped_ptr.h"
+
+struct AVCodecContext;
+struct AVFormatContext;
+
+namespace media {
+
+class BitstreamConverter;
+
+// A class to help reading and parsing input file for use in omx_test.
+class FileReader {
+ public:
+ virtual ~FileReader() {}
+
+ // Initialize FileReader object, returns true if successful.
+ virtual bool Initialize() = 0;
+
+ // Read the file into |output|, and output the number of bytes read to
+ // |size|.
+ virtual void Read(uint8** output, int* size) = 0;
+};
+
+class FFmpegFileReader : public FileReader {
+ public:
+ explicit FFmpegFileReader(const std::string& filename);
+ virtual ~FFmpegFileReader();
+ virtual bool Initialize();
+ virtual void Read(uint8** output, int* size);
+
+ // Reads a video packet, converts it into Annex B stream, and allocates a
+ // buffer to |*output| and copies the contents into it. Timestamp and
+ // duration are given in 100-ns units.
+ void Read2(uint8** output, int* size, int64* timestamp, int64* duration);
+ bool GetFrameRate(int* num, int* denom) const;
+ bool GetWidth(int* width) const;
+ bool GetHeight(int* height) const;
+ bool GetAspectRatio(int* num, int* denom) const;
+ int64 ConvertFFmpegTimeBaseTo100Ns(int64 time_base_unit) const;
+ bool end_of_stream() const { return end_of_stream_; }
+
+ private:
+ std::string filename_;
+ AVFormatContext* format_context_;
+ AVCodecContext* codec_context_;
+ int target_stream_;
+ scoped_ptr<media::BitstreamConverter> converter_;
+ bool end_of_stream_;
+
+ DISALLOW_COPY_AND_ASSIGN(FFmpegFileReader);
+};
+
+} // namespace media
+
+#endif // MEDIA_MF_FILE_READER_UTIL_H_