20 #ifndef MEDIASOURCEPIPELINE_H_
21 #define MEDIASOURCEPIPELINE_H_
23 #include <gst/app/gstappsrc.h>
40 enum ReadStatus { kDone = 0, kFrameRead, kPerformSeek };
41 enum PipelineType { kAudioVideo = 0, kAudioOnly, kVideoOnly };
43 enum AVType { kAudio = 0, kVideo };
48 int64_t timestamp_us_;
54 rtMethodNoArgAndNoReturn(
"suspend", suspend);
55 rtMethodNoArgAndNoReturn(
"resume", resume);
60 virtual void HandleKeyboardInput(
unsigned int key);
159 void StopAllTimeouts();
160 void CloseAllFiles();
162 ReadStatus GetNextFrame(
AVFrame* frame, AVType type);
163 bool PushFrameToAppSrc(
const AVFrame& frame, AVType type);
164 bool ShouldBeReading(AVType av);
165 void SetShouldBeReading(
bool is_reading, AVType av);
166 void CalculateCurrentEndTime();
167 bool ShouldPerformSeek();
168 int64_t GetCurrentStartTimeMicroseconds()
const;
169 bool IsPlaybackOver();
170 void AddPlaybackPositionToHistory(int64_t position);
171 bool IsPlaybackStalled();
172 bool HasPlaybackAdvanced();
173 void ResetPlaybackHistory();
175 void finishPipelineLinkingAndStartPlaybackIfNeeded();
177 std::string frame_files_path_;
178 int32_t current_file_counter_;
179 FILE* current_video_file_;
180 FILE* current_video_timestamp_file_;
181 FILE* current_audio_file_;
182 FILE* current_audio_timestamp_file_;
184 GstElement* pipeline_;
185 GstAppSrc* appsrc_source_video_;
186 GstAppSrc* appsrc_source_audio_;
187 GstElement* video_sink_;
188 GstElement* audio_sink_;
189 std::vector<GstElement*> ms_video_pipeline_;
190 std::vector<GstElement*> ms_audio_pipeline_;
191 bool should_be_reading_[2];
192 float playback_position_secs_;
193 float current_end_time_secs_;
194 guint video_frame_timeout_handle_;
195 guint audio_frame_timeout_handle_;
196 guint status_timeout_handle_;
197 int32_t current_playback_history_cnt_;
198 std::vector<int64_t> playback_position_history_;
199 bool playback_started_;
201 PipelineType pipeline_type_;
204 GstCaps *appsrc_caps_video_;
205 GstCaps *appsrc_caps_audio_;
206 bool pause_before_seek_;
208 int64_t seek_offset_;
212 #endif // MEDIASOURCEPIPELINE_H_