MythTV  master
httplivestream.h
Go to the documentation of this file.
1 #ifndef HTTPLIVESTREAM_H
2 #define HTTPLIVESTREAM_H
3 
4 #include <QString>
5 
6 #include "libmythtv/mythframe.h"
7 
8 enum HTTPLiveStreamStatus : std::int8_t {
17 };
18 
19 
21 {
22  public:
23  explicit HTTPLiveStream(QString srcFile, uint16_t width = 640, uint16_t height = 480,
24  uint32_t bitrate = 800000, uint32_t abitrate = 64000,
25  uint16_t maxSegments = 0, uint16_t segmentSize = 10,
26  uint32_t aobitrate = 32000, int32_t srate = -1);
27  explicit HTTPLiveStream(int streamid);
28  ~HTTPLiveStream();
29 
30  bool InitForWrite(void);
31  bool LoadFromDB(void);
32 
33  int GetStreamID(void) const { return m_streamid; }
34  uint16_t GetWidth(void) const { return m_width; }
35  uint16_t GetHeight(void) const { return m_height; }
36  uint32_t GetBitrate(void) const { return m_bitrate; }
37  uint32_t GetAudioBitrate(void) const { return m_audioBitrate; }
38  uint32_t GetAudioOnlyBitrate(void) const { return m_audioOnlyBitrate; }
39  uint16_t GetMaxSegments(void) const { return m_maxSegments; }
40  QString GetSourceFile(void) const { return m_sourceFile; }
41  QString GetHTMLPageName(void) const;
42  QString GetMetaPlaylistName(void) const;
43  QString GetPlaylistName(bool audioOnly = false) const;
44  uint16_t GetSegmentSize(void) const { return m_segmentSize; }
45  QString GetFilename(uint16_t segmentNumber = 0, bool fileOnly = false,
46  bool audioOnly = false, bool encoded = false) const;
47  QString GetCurrentFilename(
48  bool audioOnly = false, bool encoded = false) const;
49 
50  void SetOutputVars(void);
51 
52  HTTPLiveStreamStatus GetDBStatus(void) const;
53 
54  int AddStream(void);
55  bool AddSegment(void);
56 
57  bool WriteHTML(void);
58  bool WriteMetaPlaylist(void);
59  bool WritePlaylist(bool audioOnly = false, bool writeEndTag = false);
60 
61  bool SaveSegmentInfo(void);
62 
63  bool UpdateSizeInfo(uint16_t width, uint16_t height,
64  uint16_t srcwidth, uint16_t srcheight);
65  bool UpdateStatus(HTTPLiveStreamStatus status);
66  bool UpdateStatusMessage(const QString& message);
67  bool UpdatePercentComplete(int percent);
68 
69  static QString StatusToString(HTTPLiveStreamStatus status);
70 
71  bool CheckStop(void);
72 
73  protected:
74  bool m_writing {false};
75  int m_streamid {-1};
76  QString m_sourceFile;
77  QString m_sourceHost;
78  uint16_t m_sourceWidth {0};
79  uint16_t m_sourceHeight {0};
80  QString m_outDir;
81  QString m_outBase;
83  QString m_outFile;
85  QString m_audioOutFile;
87  uint16_t m_segmentSize {10};
88  uint16_t m_maxSegments {0};
89  uint16_t m_segmentCount {0};
90  uint16_t m_startSegment {0};
91  uint16_t m_curSegment {0};
92  QString m_httpPrefix;
93  QString m_httpPrefixRel;
94  uint16_t m_height {480};
95  uint16_t m_width {640};
96  uint32_t m_bitrate {800000};
97  uint32_t m_audioBitrate { 64000};
98  uint32_t m_audioOnlyBitrate { 32000};
99  int32_t m_sampleRate {-1};
100 
101  QDateTime m_created;
102  QDateTime m_lastModified;
103  uint16_t m_percentComplete {0};
104  QString m_relativeURL;
105  QString m_fullURL;
107 
109 };
110 
111 #endif
112 
113 /* vim: set expandtab tabstop=4 shiftwidth=4: */
114 
HTTPLiveStream::GetSourceFile
QString GetSourceFile(void) const
Definition: httplivestream.h:40
HTTPLiveStream::GetWidth
uint16_t GetWidth(void) const
Definition: httplivestream.h:34
HTTPLiveStream::m_outBaseEncoded
QString m_outBaseEncoded
Definition: httplivestream.h:82
HTTPLiveStream::m_outBase
QString m_outBase
Definition: httplivestream.h:81
HTTPLiveStream::m_fullURL
QString m_fullURL
Definition: httplivestream.h:105
HTTPLiveStream::m_relativeURL
QString m_relativeURL
Definition: httplivestream.h:104
kHLSStatusRunning
@ kHLSStatusRunning
Definition: httplivestream.h:12
kHLSStatusCompleted
@ kHLSStatusCompleted
Definition: httplivestream.h:13
HTTPLiveStream::m_httpPrefixRel
QString m_httpPrefixRel
Definition: httplivestream.h:93
HTTPLiveStream::m_lastModified
QDateTime m_lastModified
Definition: httplivestream.h:102
kHLSStatusQueued
@ kHLSStatusQueued
Definition: httplivestream.h:10
kHLSStatusStopped
@ kHLSStatusStopped
Definition: httplivestream.h:16
kHLSStatusStopping
@ kHLSStatusStopping
Definition: httplivestream.h:15
mythframe.h
HTTPLiveStream::m_outFile
QString m_outFile
Definition: httplivestream.h:83
HTTPLiveStream::GetMaxSegments
uint16_t GetMaxSegments(void) const
Definition: httplivestream.h:39
HTTPLiveStream::GetSegmentSize
uint16_t GetSegmentSize(void) const
Definition: httplivestream.h:44
HTTPLiveStream::m_audioOutFile
QString m_audioOutFile
Definition: httplivestream.h:85
HTTPLiveStream::GetAudioBitrate
uint32_t GetAudioBitrate(void) const
Definition: httplivestream.h:37
HTTPLiveStream::m_outFileEncoded
QString m_outFileEncoded
Definition: httplivestream.h:84
HTTPLiveStream::m_sourceHost
QString m_sourceHost
Definition: httplivestream.h:77
HTTPLiveStream::GetBitrate
uint32_t GetBitrate(void) const
Definition: httplivestream.h:36
HTTPLiveStream::GetAudioOnlyBitrate
uint32_t GetAudioOnlyBitrate(void) const
Definition: httplivestream.h:38
HTTPLiveStream::m_outDir
QString m_outDir
Definition: httplivestream.h:80
HTTPLiveStream::m_audioOutFileEncoded
QString m_audioOutFileEncoded
Definition: httplivestream.h:86
HTTPLiveStream::GetHeight
uint16_t GetHeight(void) const
Definition: httplivestream.h:35
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
HTTPLiveStream::GetStreamID
int GetStreamID(void) const
Definition: httplivestream.h:33
kHLSStatusUndefined
@ kHLSStatusUndefined
Definition: httplivestream.h:9
HTTPLiveStream
Definition: httplivestream.h:20
kHLSStatusStarting
@ kHLSStatusStarting
Definition: httplivestream.h:11
HTTPLiveStream::m_sourceFile
QString m_sourceFile
Definition: httplivestream.h:76
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3
HTTPLiveStream::m_created
QDateTime m_created
Definition: httplivestream.h:101
HTTPLiveStream::m_statusMessage
QString m_statusMessage
Definition: httplivestream.h:106
HTTPLiveStreamStatus
HTTPLiveStreamStatus
Definition: httplivestream.h:8
kHLSStatusErrored
@ kHLSStatusErrored
Definition: httplivestream.h:14
HTTPLiveStream::m_httpPrefix
QString m_httpPrefix
Definition: httplivestream.h:92