libwebm_utils: Add FileDeleter.

Put the FILE clean up functor in a common place to avoid duplication.

Change-Id: I7bcb5b3e4df7aa37bb90920ecb8acccf94eeaa57
This commit is contained in:
Tom Finegan 2015-12-16 17:31:58 -08:00
parent d6db1e1960
commit be35869ce3
2 changed files with 12 additions and 10 deletions

View File

@ -13,6 +13,16 @@
namespace libwebm {
// fclose functor for wrapping FILE in std::unique_ptr.
struct FILEDeleter {
int operator()(FILE* f) {
if (f != nullptr)
return fclose(f);
return 0;
}
};
typedef std::unique_ptr<FILE, FILEDeleter> FilePtr;
struct Range {
Range(std::size_t off, std::size_t len) : offset(off), length(len) {}
Range() = delete;

View File

@ -15,6 +15,8 @@
#include "mkvparser.hpp"
#include "mkvreader.hpp"
#include "common/libwebm_utils.h"
namespace libwebm {
// Stores a value and its size in bits for writing into a PES Optional Header.
@ -174,16 +176,6 @@ class Webm2Pes {
bool ConvertToFile();
private:
// fclose functor for wrapping FILE in std::unique_ptr.
struct FILEDeleter {
int operator()(FILE* f) {
if (f != nullptr)
return fclose(f);
return 0;
}
};
typedef std::unique_ptr<FILE, FILEDeleter> FilePtr;
bool InitWebmParser();
bool WritePesPacket(const mkvparser::Block::Frame& vpx_frame,
double nanosecond_pts);