-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_context.h
More file actions
54 lines (41 loc) · 1.29 KB
/
Copy pathformat_context.h
File metadata and controls
54 lines (41 loc) · 1.29 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
#pragma once
extern "C"
{
#include <libavformat/avformat.h>
}
struct AVCodecContext;
#include <stdexcept>
class FormatContext final
{
FormatContext(const FormatContext&) = delete;
const FormatContext& operator=(const FormatContext&) = delete;
FormatContext(FormatContext&&) = delete;
const FormatContext& operator=(FormatContext&&) = delete;
public:
FormatContext();
~FormatContext();
void OpenInput(const char* filename) throw (std::logic_error, std::runtime_error);
void FindStreamInfo() throw (std::logic_error, std::runtime_error);
int FindFirstStreamByType(int type) throw (std::logic_error);
AVCodecContext* GetCodecContext(int stream_idx) const throw (std::logic_error);
/* TO DO: unify these methods under single class template
* ex.
* template <typename T>
* class Resource
* {
* public:
* T* operator->() const noexcept { return _resource; }
* operator T*() const noexcept { return _resource; }
* operator bool() const noexcept { return _resource != NULL; }
* protected:
* T* _resource;
* };
*/
AVFormatContext* operator->() const noexcept
{ return _format_context; }
operator AVFormatContext*() const noexcept
{ return _format_context; }
operator bool() const noexcept { return _format_context != NULL; }
private:
AVFormatContext* _format_context;
};