Ocean
Loading...
Searching...
No Matches
FFMMedium.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_MEDIA_FFM_MEDIUM_H
9#define META_OCEAN_MEDIA_FFM_MEDIUM_H
10
12
13#include "ocean/media/Medium.h"
14
15// Forward declaration.
16struct AVFormatContext;
17
18namespace Ocean
19{
20
21namespace Media
22{
23
24namespace FFmpeg
25{
26
27/**
28 * This is the base class for all FFmpeg mediums.
29 * @ingroup mediaffm
30 */
31class FFMMedium : virtual public Medium
32{
33 public:
34
35 /**
36 * Returns whether the medium is started currently.
37 * @see Medium::isStarted()
38 */
39 bool isStarted() const override;
40
41 /**
42 * Returns the start timestamp.
43 * @return Start timestamp
44 */
45 Timestamp startTimestamp() const override;
46
47 /**
48 * Returns the pause timestamp.
49 * @return Pause timestamp
50 */
51 Timestamp pauseTimestamp() const override;
52
53 /**
54 * Returns the stop timestamp.
55 * @return Stop timestamp
56 */
57 Timestamp stopTimestamp() const override;
58
59 protected:
60
61 /**
62 * Creates a new medium by a given url.
63 * @param url Url of the medium
64 */
65 explicit FFMMedium(const std::string& url);
66
67 /**
68 * Destructs a FFMMedium object.
69 */
70 ~FFMMedium() override;
71
72 /**
73 * Starts the medium.
74 * The internalStart() function will be called inside.
75 * @see Medium::start()
76 */
77 bool start() override;
78
79 /**
80 * Pauses the medium.
81 * The internalPause() function will be called inside.
82 * @see Medium::pause()
83 */
84 bool pause() override;
85
86 /**
87 * Stops the medium.
88 * The internalStop() function will be called inside.
89 * @see Medium::stop()
90 */
91 bool stop() override;
92
93 /**
94 * Internally starts the medium.
95 * @return True, if succeeded or if the medium is already started
96 */
97 virtual bool internalStart() = 0;
98
99 /**
100 * Internally pauses the medium.
101 * @return True, if succeeded or if the medium is already paused
102 */
103 virtual bool internalPause() = 0;
104
105 /**
106 * Internally stops the medium.
107 * @return True, if succeeded or if the medium is already stopped
108 */
109 virtual bool internalStop() = 0;
110
111 /**
112 * Creates a FFmpeg context and opens a given file.
113 * @param filename The name of the file to open, must be valid
114 * @return True, if succeeded
115 */
116 bool createContextAndOpenFile(const std::string& filename);
117
118 /**
119 * Releases the FFmpeg context.
120 */
122
123 protected:
124
125 /// FFmpeg's format context object.
126 AVFormatContext* avFormatContext_ = nullptr;
127
128 /// Start timestamp
130
131 /// Pause timestamp
133
134 /// Stop timestamp
136};
137
138}
139
140}
141
142}
143
144#endif // META_OCEAN_MEDIA_FFM_MEDIUM_H
This is the base class for all FFmpeg mediums.
Definition FFMMedium.h:32
Timestamp pauseTimestamp() const override
Returns the pause timestamp.
virtual bool internalStart()=0
Internally starts the medium.
FFMMedium(const std::string &url)
Creates a new medium by a given url.
bool start() override
Starts the medium.
virtual bool internalStop()=0
Internally stops the medium.
bool pause() override
Pauses the medium.
Timestamp stopTimestamp_
Stop timestamp.
Definition FFMMedium.h:135
Timestamp pauseTimestamp_
Pause timestamp.
Definition FFMMedium.h:132
AVFormatContext * avFormatContext_
FFmpeg's format context object.
Definition FFMMedium.h:126
Timestamp startTimestamp_
Start timestamp.
Definition FFMMedium.h:129
bool stop() override
Stops the medium.
Timestamp startTimestamp() const override
Returns the start timestamp.
void releaseContext()
Releases the FFmpeg context.
bool createContextAndOpenFile(const std::string &filename)
Creates a FFmpeg context and opens a given file.
Timestamp stopTimestamp() const override
Returns the stop timestamp.
virtual bool internalPause()=0
Internally pauses the medium.
bool isStarted() const override
Returns whether the medium is started currently.
~FFMMedium() override
Destructs a FFMMedium object.
This is the base class for all mediums.
Definition Medium.h:48
const std::string & url() const
Returns the url of the medium.
Definition Medium.h:236
This class implements a timestamp.
Definition Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition Accessor.h:15