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:
parent
d6db1e1960
commit
be35869ce3
@ -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;
|
||||
|
12
webm2pes.h
12
webm2pes.h
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user