forked from mikrosimage/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputFile.hpp
More file actions
119 lines (99 loc) · 3.34 KB
/
Copy pathInputFile.hpp
File metadata and controls
119 lines (99 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef _AV_TRANSCODER_FILE_INPUT_FILE_HPP_
#define _AV_TRANSCODER_FILE_INPUT_FILE_HPP_
#include <AvTranscoder/common.hpp>
#include <AvTranscoder/file/util.hpp>
#include <AvTranscoder/file/FormatContext.hpp>
#include <AvTranscoder/stream/InputStream.hpp>
#include <AvTranscoder/mediaProperty/FileProperties.hpp>
#include <AvTranscoder/progress/IProgress.hpp>
#include <AvTranscoder/profile/ProfileLoader.hpp>
#include <string>
#include <vector>
namespace avtranscoder
{
class AvExport InputFile
{
public:
/**
* @brief Open a media file
* @note The constructor also analyses header of input file
* @param filename resource to access
* @exception ios_base::failure launched if unable to open file
**/
InputFile( const std::string& filename );
virtual ~InputFile();
/**
* @brief Run the analyse on the file after a setup.
* call this function before getProperties().
* @param progress callback to get analysis progression
* @param level by default eAnalyseLevelFirstGop
**/
void analyse( IProgress& progress, const EAnalyseLevel level = eAnalyseLevelFirstGop );
/**
* @brief Read the next packet of the specified stream
* @param data: data of next packet read
* @return if next packet was read succefully
**/
bool readNextPacket( CodedData& data, const size_t streamIndex );
/**
* @brief Seek input stream at specified frame
* @note clean also buffers in each InputStream
* @return if next packet was read succefully
**/
void seekAtFrame( const size_t frame );
void seekAtTime( const double time );
/**
* @brief Activate the indicated stream
* @note Activate a stream results in buffered its data when processing
**/
void activateStream( const size_t streamIndex, const bool activate = true );
/**
* @return Return the resource to access
**/
std::string getFilename() const { return _filename; }
/**
* @brief Return media properties on the current InputFile.
* @note require to launch analyse() before to fill the property struture
* @return structure of media metadatas
**/
const FileProperties& getProperties() const { return _properties; }
/**
* @brief Get stream type: video, audio, subtitle, etc.
* @param index stream index
* @return media stream type of specified index stream
**/
InputStream& getStream( size_t index );
FormatContext& getFormatContext() { return _formatContext; }
/**
* @brief Set the format of the input file
* @param profile: the profile of the input format
*/
virtual void setProfile( const ProfileLoader::Profile& profile );
public:
/**
* @brief Get media file properties using static method.
* @param filename input filename
* @param progress callback to get analysis progression
* @return structure of media metadatas
**/
static FileProperties analyseFile( const std::string& filename, IProgress& progress, const EAnalyseLevel level = eAnalyseLevelFirstGop );
private:
/**
* @brief Get Fps from first video stream
* @note if there is no video stream, return 1.
*/
double getFps();
/**
* @brief Seek at a specific position (in AV_TIME_BASE units)
* @note before seek, add offset of start time
* @note after seek, clear buffering of streams
*/
void seek( uint64_t position );
protected:
FormatContext _formatContext;
FileProperties _properties;
std::string _filename;
std::vector<InputStream*> _inputStreams; ///< Has ownership
};
}
#endif