RDK Documentation (Open Sourced RDK Components)
webvttParser.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file webvttParser.h
22  *
23  * @brief WebVTT parser implementation for AAMP
24  *
25  */
26 
27 #ifndef __WEBVTT_PARSER_H__
28 #define __WEBVTT_PARSER_H__
29 
30 #include <queue>
31 #include <pthread.h>
32 #include "subtitleParser.h"
33 #include "vttCue.h"
34 
35 
36 /**
37 * \struct CueTimeStamp
38 * \brief Hold timestamps of a cue
39 *
40 * Structure to hold timestamps of previously parsed cues
41 * This is required since in playlists a single cue may be
42 * advertised twice
43 */
44 typedef struct {
45  double mStart;
46  double mDuration;
47 } CueTimeStamp;
48 
49 
50 /**
51 * \class WebVTTParser
52 * \brief WebVTT parser class
53 *
54 * Class for WebVTT parser implementation in AAMP
55 */
57 {
58 
59 public:
61  virtual ~WebVTTParser();
62 
63  virtual bool init(double startPosSeconds, unsigned long long basePTS);
64  virtual bool processData(char *buffer, size_t bufferLen, double position, double duration);
65  virtual bool close();
66  virtual void reset();
67  virtual void setProgressEventOffset(double offset) { mProgressOffset = offset; }
68 
69  virtual void addCueData(VTTCue *cue);
70  virtual void sendCueData();
71  virtual void updateTimestamp(unsigned long long positionMs) {}
72 
73 protected:
74  unsigned long long mStartPTS; /**< start/base PTS for current period */
75  unsigned long long mPtsOffset; /**< offset between cue local time and MPEG time */
76  double mStartPos; /**< position of first fragment in playlist */
77  double mCurrentPos; /**< current fragment position in playlist */
78  bool mReset; /**< true if waiting for first fragment after processing a discontinuity or at start */
79 
80  CueTimeStamp lastCue; /**< holds timestamp of last parsed cue */
81 
82  std::queue<VTTCue*> mVttQueue; /**< queue for storing parsed cues */
83  guint mVttQueueIdleTaskId; /**< task id for handler that sends cues upstream */
84  pthread_mutex_t mVttQueueMutex; /**< mutex for synchronising queue access */
85  double mProgressOffset; /**< offset value in progress event compared to playlist position */
86 
87 };
88 
89 #endif /* __WEBVTT_PARSER_H__ */
subtitleParser.h
This file provides interfaces for a subtitle parser in AAMP.
WebVTTParser::mProgressOffset
double mProgressOffset
Definition: webvttParser.h:85
vttCue.h
Provides data structure to hold a WebVTT cue data.
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
WebVTTParser::mVttQueueMutex
pthread_mutex_t mVttQueueMutex
Definition: webvttParser.h:84
WebVTTParser::mReset
bool mReset
Definition: webvttParser.h:78
WebVTTParser::mPtsOffset
unsigned long long mPtsOffset
Definition: webvttParser.h:75
WebVTTParser::mStartPTS
unsigned long long mStartPTS
Definition: webvttParser.h:74
SubtitleMimeType
SubtitleMimeType
Subtitle data types.
Definition: subtitleParser.h:37
VTTCue
Data structure to hold a VTT cue.
Definition: vttCue.h:39
WebVTTParser::mCurrentPos
double mCurrentPos
Definition: webvttParser.h:77
WebVTTParser::lastCue
CueTimeStamp lastCue
Definition: webvttParser.h:80
WebVTTParser::mStartPos
double mStartPos
Definition: webvttParser.h:76
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
WebVTTParser::mVttQueueIdleTaskId
guint mVttQueueIdleTaskId
Definition: webvttParser.h:83
CueTimeStamp
Hold timestamps of a cue.
Definition: webvttParser.h:44
WebVTTParser::mVttQueue
std::queue< VTTCue * > mVttQueue
Definition: webvttParser.h:82
WebVTTParser
WebVTT parser class.
Definition: webvttParser.h:56
SubtitleParser
Subtitle parser class.
Definition: subtitleParser.h:52