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:
@@ -13,6 +13,16 @@
|
|||||||
|
|
||||||
namespace libwebm {
|
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 {
|
struct Range {
|
||||||
Range(std::size_t off, std::size_t len) : offset(off), length(len) {}
|
Range(std::size_t off, std::size_t len) : offset(off), length(len) {}
|
||||||
Range() = delete;
|
Range() = delete;
|
||||||
|
|||||||
12
webm2pes.h
12
webm2pes.h
@@ -15,6 +15,8 @@
|
|||||||
#include "mkvparser.hpp"
|
#include "mkvparser.hpp"
|
||||||
#include "mkvreader.hpp"
|
#include "mkvreader.hpp"
|
||||||
|
|
||||||
|
#include "common/libwebm_utils.h"
|
||||||
|
|
||||||
namespace libwebm {
|
namespace libwebm {
|
||||||
|
|
||||||
// Stores a value and its size in bits for writing into a PES Optional Header.
|
// Stores a value and its size in bits for writing into a PES Optional Header.
|
||||||
@@ -174,16 +176,6 @@ class Webm2Pes {
|
|||||||
bool ConvertToFile();
|
bool ConvertToFile();
|
||||||
|
|
||||||
private:
|
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 InitWebmParser();
|
||||||
bool WritePesPacket(const mkvparser::Block::Frame& vpx_frame,
|
bool WritePesPacket(const mkvparser::Block::Frame& vpx_frame,
|
||||||
double nanosecond_pts);
|
double nanosecond_pts);
|
||||||
|
|||||||
Reference in New Issue
Block a user