Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change members prototype.

- Remove use of references (make it too painful to parse arguments sometimes)
- Mark arguments and functions as const when appropriate
  • Loading branch information...
commit 83872a3618264e4384c110bfe4753befd979a3c9 1 parent a99e92c
Jean-Yves Avenard authored December 27, 2012
150  mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
@@ -56,14 +56,14 @@ enum
56 56
 
57 57
 /* utility methods */
58 58
 
59  
-static QString decoded_URI(QString uri)
  59
+static QString decoded_URI(const QString uri)
60 60
 {
61 61
     QByteArray ba   = uri.toAscii();
62 62
     QUrl url        = QUrl::fromEncoded(ba);
63 63
     return url.toString();
64 64
 }
65 65
 
66  
-static QString relative_URI(QString &surl, QString &spath)
  66
+static QString relative_URI(const QString surl, const QString spath)
67 67
 {
68 68
     QUrl url  = QUrl(surl);
69 69
     QUrl path = QUrl(spath);
@@ -82,13 +82,13 @@ static uint64_t mdate(void)
82 82
     return t.tv_sec * 1000000ULL + t.tv_usec;
83 83
 }
84 84
 
85  
-static bool downloadURL(QString url, QByteArray *buffer)
  85
+static bool downloadURL(const QString url, QByteArray *buffer)
86 86
 {
87 87
     MythDownloadManager *mdm = GetMythDownloadManager();
88 88
     return mdm->download(url, buffer);
89 89
 }
90 90
 
91  
-static void cancelURL(QString url)
  91
+static void cancelURL(const QString url)
92 92
 {
93 93
     MythDownloadManager *mdm = GetMythDownloadManager();
94 94
     mdm->cancelDownload(url);
@@ -99,8 +99,8 @@ static void cancelURL(QString url)
99 99
 class HLSSegment
100 100
 {
101 101
 public:
102  
-    HLSSegment(const int mduration, const int id, QString &title,
103  
-               QString &uri, QString &current_key_path)
  102
+    HLSSegment(const int mduration, const int id, const QString title,
  103
+               const QString uri, const QString current_key_path)
104 104
     {
105 105
         m_duration      = mduration; /* seconds */
106 106
         m_id            = id;
@@ -145,12 +145,12 @@ class HLSSegment
145 145
         return *this;
146 146
     }
147 147
 
148  
-    int Duration(void)
  148
+    int Duration(void) const
149 149
     {
150 150
         return m_duration;
151 151
     }
152 152
 
153  
-    int Id(void)
  153
+    int Id(void) const
154 154
     {
155 155
         return m_id;
156 156
     }
@@ -165,12 +165,12 @@ class HLSSegment
165 165
         m_lock.unlock();
166 166
     }
167 167
 
168  
-    bool IsEmpty(void)
  168
+    bool IsEmpty(void) const
169 169
     {
170 170
         return m_data.isEmpty();
171 171
     }
172 172
 
173  
-    int32_t Size(void)
  173
+    int32_t Size(void) const
174 174
     {
175 175
         return m_data.size();
176 176
     }
@@ -200,12 +200,12 @@ class HLSSegment
200 200
         }
201 201
     }
202 202
 
203  
-    QString Url(void)
  203
+    QString Url(void) const
204 204
     {
205 205
         return m_url;
206 206
     }
207 207
 
208  
-    int32_t SizePlayed(void)
  208
+    int32_t SizePlayed(void) const
209 209
     {
210 210
         return m_played;
211 211
     }
@@ -241,18 +241,18 @@ class HLSSegment
241 241
         m_data.clear();
242 242
     }
243 243
 
244  
-    QString Title(void)
  244
+    QString Title(void) const
245 245
     {
246 246
         return m_title;
247 247
     }
248  
-    void SetTitle(QString &x)
  248
+    void SetTitle(const QString x)
249 249
     {
250 250
         m_title = x;
251 251
     }
252 252
     /**
253 253
      * provides pointer to raw segment data
254 254
      */
255  
-    const char *Data(void)
  255
+    const char *Data(void) const
256 256
     {
257 257
         return m_data.constData();
258 258
     }
@@ -277,7 +277,7 @@ class HLSSegment
277 277
         return RET_OK;
278 278
     }
279 279
 
280  
-    int DecodeData(uint8_t *IV)
  280
+    int DecodeData(const uint8_t *IV)
281 281
     {
282 282
         /* Decrypt data using AES-128 */
283 283
         int aeslen = m_data.size() & ~0xf;
@@ -323,27 +323,27 @@ class HLSSegment
323 323
         return RET_OK;
324 324
     }
325 325
 
326  
-    bool HasKeyPath(void)
  326
+    bool HasKeyPath(void) const
327 327
     {
328 328
         return !m_psz_key_path.isEmpty();
329 329
     }
330 330
 
331  
-    bool KeyLoaded(void)
  331
+    bool KeyLoaded(void) const
332 332
     {
333 333
         return m_keyloaded;
334 334
     }
335 335
 
336  
-    QString KeyPath(void)
  336
+    QString KeyPath(void) const
337 337
     {
338 338
         return m_psz_key_path;
339 339
     }
340 340
 
341  
-    void SetKeyPath(QString &path)
  341
+    void SetKeyPath(const QString path)
342 342
     {
343 343
         m_psz_key_path = path;
344 344
     }
345 345
 
346  
-    void CopyAESKey(HLSSegment &segment)
  346
+    void CopyAESKey(const HLSSegment &segment)
347 347
     {
348 348
         memcpy(&m_aeskey, &(segment.m_aeskey), sizeof(m_aeskey));
349 349
         m_keyloaded = segment.m_keyloaded;
@@ -372,7 +372,7 @@ class HLSSegment
372 372
 class HLSStream
373 373
 {
374 374
 public:
375  
-    HLSStream(const int mid, const uint64_t bitrate, QString &uri)
  375
+    HLSStream(const int mid, const uint64_t bitrate, const QString uri)
376 376
     {
377 377
         m_id            = mid;
378 378
         m_bitrate       = bitrate;
@@ -389,7 +389,7 @@ class HLSStream
389 389
 #endif
390 390
     }
391 391
 
392  
-    HLSStream(HLSStream &rhs, bool copy = true)
  392
+    HLSStream(const HLSStream &rhs, bool copy = true)
393 393
     {
394 394
         (*this) = rhs;
395 395
         if (!copy)
@@ -440,12 +440,12 @@ class HLSStream
440 440
         return s1->Bitrate() > s2->Bitrate();
441 441
     }
442 442
 
443  
-    bool operator<(HLSStream &b)
  443
+    bool operator<(const HLSStream &b) const
444 444
     {
445 445
         return this->Bitrate() < b.Bitrate();
446 446
     }
447 447
 
448  
-    bool operator>(HLSStream &b)
  448
+    bool operator>(const HLSStream &b) const
449 449
     {
450 450
         return this->Bitrate() > b.Bitrate();
451 451
     }
@@ -461,11 +461,12 @@ class HLSStream
461 461
             return m_size;
462 462
         QMutexLocker lock(&m_lock);
463 463
 
464  
-        int64_t size = 0;
465  
-        int count = NumSegments();
  464
+        int64_t size    = 0;
  465
+        int count       = NumSegments();
  466
+
466 467
         for (int i = 0; i < count; i++)
467 468
         {
468  
-            HLSSegment *segment    = GetSegment(i);
  469
+            HLSSegment *segment = GetSegment(i);
469 470
             segment->Lock();
470 471
             if (segment->Size() > 0)
471 472
             {
@@ -492,7 +493,7 @@ class HLSStream
492 493
         m_segments.clear();
493 494
     }
494 495
 
495  
-    int NumSegments(void)
  496
+    int NumSegments(void) const
496 497
     {
497 498
         return m_segments.size();
498 499
     }
@@ -503,7 +504,7 @@ class HLSStream
503 504
         m_segments.append(segment);
504 505
     }
505 506
 
506  
-    HLSSegment *GetSegment(const int wanted)
  507
+    HLSSegment *GetSegment(const int wanted) const
507 508
     {
508 509
         int count = NumSegments();
509 510
         if (count <= 0)
@@ -513,7 +514,7 @@ class HLSStream
513 514
         return m_segments[wanted];
514 515
     }
515 516
 
516  
-    HLSSegment *FindSegment(const int id, int *segnum = NULL)
  517
+    HLSSegment *FindSegment(const int id, int *segnum = NULL) const
517 518
     {
518 519
         int count = NumSegments();
519 520
         if (count <= 0)
@@ -535,7 +536,7 @@ class HLSStream
535 536
         return NULL;
536 537
     }
537 538
 
538  
-    void AddSegment(const int duration, QString &title, QString &uri)
  539
+    void AddSegment(const int duration, const QString title, const QString uri)
539 540
     {
540 541
         QMutexLocker lock(&m_lock);
541 542
         QString psz_uri = relative_URI(m_url, uri);
@@ -590,7 +591,7 @@ class HLSStream
590 591
         for (it = table.begin(); it != table.end(); ++it)
591 592
         {
592 593
             bool todelete   = *it;
593  
-            HLSSegment *p  = it.key();
  594
+            HLSSegment *p   = it.key();
594 595
             RemoveSegment(p, todelete);
595 596
         }
596 597
     }
@@ -690,7 +691,7 @@ class HLSStream
690 691
     {
691 692
         return m_id;
692 693
     }
693  
-    int Version(void)
  694
+    int Version(void) const
694 695
     {
695 696
         return m_version;
696 697
     }
@@ -698,7 +699,7 @@ class HLSStream
698 699
     {
699 700
         m_version = x;
700 701
     }
701  
-    int StartSequence(void)
  702
+    int StartSequence(void) const
702 703
     {
703 704
         return m_startsequence;
704 705
     }
@@ -706,7 +707,7 @@ class HLSStream
706 707
     {
707 708
         m_startsequence = x;
708 709
     }
709  
-    int TargetDuration(void)
  710
+    int TargetDuration(void) const
710 711
     {
711 712
         return m_targetduration;
712 713
     }
@@ -718,7 +719,7 @@ class HLSStream
718 719
     {
719 720
         return m_bitrate;
720 721
     }
721  
-    bool Cache(void)
  722
+    bool Cache(void) const
722 723
     {
723 724
         return m_cache;
724 725
     }
@@ -726,7 +727,7 @@ class HLSStream
726 727
     {
727 728
         m_cache = x;
728 729
     }
729  
-    bool Live(void)
  730
+    bool Live(void) const
730 731
     {
731 732
         return m_live;
732 733
     }
@@ -742,11 +743,11 @@ class HLSStream
742 743
     {
743 744
         m_lock.unlock();
744 745
     }
745  
-    QString Url(void)
  746
+    QString Url(void) const
746 747
     {
747 748
         return m_url;
748 749
     }
749  
-    void UpdateWith(HLSStream &upd)
  750
+    void UpdateWith(const HLSStream &upd)
750 751
     {
751 752
         QMutexLocker lock(&m_lock);
752 753
         m_targetduration    = upd.m_targetduration < 0 ?
@@ -801,7 +802,7 @@ class HLSStream
801 802
         }
802 803
         return RET_OK;
803 804
     }
804  
-    bool SetAESIV(QString &line)
  805
+    bool SetAESIV(QString line)
805 806
     {
806 807
         /*
807 808
          * If the EXT-X-KEY tag has the IV attribute, implementations MUST use
@@ -827,7 +828,7 @@ class HLSStream
827 828
     {
828 829
         return m_AESIV;
829 830
     }
830  
-    void SetKeyPath(QString &x)
  831
+    void SetKeyPath(const QString x)
831 832
     {
832 833
         m_keypath = x;
833 834
     }
@@ -863,7 +864,7 @@ class HLSPlayback
863 864
     {
864 865
     }
865 866
     /* offset is only used from main thread, no need for locking */
866  
-    uint64_t Offset(void)
  867
+    uint64_t Offset(void) const
867 868
     {
868 869
         return m_offset;
869 870
     }
@@ -970,7 +971,7 @@ class StreamWorker : public MThread
970 971
     /**
971 972
      * check that we have at least [count] segments buffered from position [from]
972 973
      */
973  
-    bool GotBufferedSegments(int from, int count)
  974
+    bool GotBufferedSegments(int from, int count) const
974 975
     {
975 976
         if (from + count > m_parent->NumSegments())
976 977
             return false;
@@ -1063,7 +1064,7 @@ class StreamWorker : public MThread
1063 1064
     {
1064 1065
         m_lock.unlock();
1065 1066
     }
1066  
-    int64_t Bandwidth(void)
  1067
+    int64_t Bandwidth(void) const
1067 1068
     {
1068 1069
         return m_bandwidth;
1069 1070
     }
@@ -1181,7 +1182,7 @@ class StreamWorker : public MThread
1181 1182
         RunEpilog();
1182 1183
     }
1183 1184
 
1184  
-    int BandwidthAdaptation(int progid, uint64_t &bandwidth)
  1185
+    int BandwidthAdaptation(int progid, uint64_t &bandwidth) const
1185 1186
     {
1186 1187
         int candidate = -1;
1187 1188
         uint64_t bw = bandwidth;
@@ -1578,7 +1579,7 @@ HLSRingBuffer::~HLSRingBuffer()
1578 1579
     }
1579 1580
 }
1580 1581
 
1581  
-void HLSRingBuffer::FreeStreamsList(StreamsList *streams)
  1582
+void HLSRingBuffer::FreeStreamsList(StreamsList *streams) const
1582 1583
 {
1583 1584
     /* Free hls streams */
1584 1585
     for (int i = 0; i < streams->size(); i++)
@@ -1596,7 +1597,7 @@ void HLSRingBuffer::FreeStreamsList(StreamsList *streams)
1596 1597
     }
1597 1598
 }
1598 1599
 
1599  
-HLSStream *HLSRingBuffer::GetStreamForSegment(int segnum)
  1600
+HLSStream *HLSRingBuffer::GetStreamForSegment(int segnum) const
1600 1601
 {
1601 1602
     int stream = m_streamworker->StreamForSegment(segnum);
1602 1603
     if (stream < 0)
@@ -1620,12 +1621,12 @@ HLSStream *HLSRingBuffer::GetStream(const int wanted, const StreamsList *streams
1620 1621
     return streams->at(wanted);
1621 1622
 }
1622 1623
 
1623  
-HLSStream *HLSRingBuffer::GetFirstStream(const StreamsList *streams)
  1624
+HLSStream *HLSRingBuffer::GetFirstStream(const StreamsList *streams) const
1624 1625
 {
1625 1626
     return GetStream(0, streams);
1626 1627
 }
1627 1628
 
1628  
-HLSStream *HLSRingBuffer::GetLastStream(const StreamsList *streams)
  1629
+HLSStream *HLSRingBuffer::GetLastStream(const StreamsList *streams) const
1629 1630
 {
1630 1631
     if (streams == NULL)
1631 1632
     {
@@ -1639,7 +1640,7 @@ HLSStream *HLSRingBuffer::GetLastStream(const StreamsList *streams)
1639 1640
 }
1640 1641
 
1641 1642
 HLSStream *HLSRingBuffer::FindStream(const HLSStream *hls_new,
1642  
-                                     const StreamsList *streams)
  1643
+                                     const StreamsList *streams) const
1643 1644
 {
1644 1645
     if (streams == NULL)
1645 1646
     {
@@ -1709,7 +1710,7 @@ bool HLSRingBuffer::IsHTTPLiveStreaming(QByteArray *s)
1709 1710
     return false;
1710 1711
 }
1711 1712
 
1712  
-bool HLSRingBuffer::TestForHTTPLiveStreaming(QString &filename)
  1713
+bool HLSRingBuffer::TestForHTTPLiveStreaming(const QString filename)
1713 1714
 {
1714 1715
     bool isHLS = false;
1715 1716
     avcodeclock->lock();
@@ -1744,7 +1745,7 @@ bool HLSRingBuffer::TestForHTTPLiveStreaming(QString &filename)
1744 1745
 }
1745 1746
 
1746 1747
 /* Parsing */
1747  
-QString HLSRingBuffer::ParseAttributes(QString &line, const char *attr)
  1748
+QString HLSRingBuffer::ParseAttributes(const QString line, const char *attr) const
1748 1749
 {
1749 1750
     int p = line.indexOf(QLatin1String(":"));
1750 1751
     if (p < 0)
@@ -1770,7 +1771,7 @@ QString HLSRingBuffer::ParseAttributes(QString &line, const char *attr)
1770 1771
  * Return the decimal argument in a line of type: blah:<decimal>
1771 1772
  * presence of valud <decimal> is compulsory or it will return RET_ERROR
1772 1773
  */
1773  
-int HLSRingBuffer::ParseDecimalValue(QString &line, int &target)
  1774
+int HLSRingBuffer::ParseDecimalValue(const QString line, int &target) const
1774 1775
 {
1775 1776
     int p = line.indexOf(QLatin1String(":"));
1776 1777
     if (p < 0)
@@ -1783,8 +1784,8 @@ int HLSRingBuffer::ParseDecimalValue(QString &line, int &target)
1783 1784
     return RET_OK;
1784 1785
 }
1785 1786
 
1786  
-int HLSRingBuffer::ParseSegmentInformation(HLSStream *hls, QString &line,
1787  
-                                           int &duration, QString &title)
  1787
+int HLSRingBuffer::ParseSegmentInformation(const HLSStream *hls, const QString line,
  1788
+                                           int &duration, QString &title) const
1788 1789
 {
1789 1790
     /*
1790 1791
      * #EXTINF:<duration>,<title>
@@ -1841,14 +1842,14 @@ int HLSRingBuffer::ParseSegmentInformation(HLSStream *hls, QString &line,
1841 1842
     return RET_OK;
1842 1843
 }
1843 1844
 
1844  
-int HLSRingBuffer::ParseTargetDuration(HLSStream *hls, QString &line)
  1845
+int HLSRingBuffer::ParseTargetDuration(HLSStream *hls, const QString line) const
1845 1846
 {
1846 1847
     /*
1847 1848
      * #EXT-X-TARGETDURATION:<s>
1848 1849
      *
1849 1850
      * where s is an integer indicating the target duration in seconds.
1850 1851
      */
1851  
-    int duration       = -1;
  1852
+    int duration = -1;
1852 1853
 
1853 1854
     if (ParseDecimalValue(line, duration) != RET_OK)
1854 1855
     {
@@ -1859,7 +1860,7 @@ int HLSRingBuffer::ParseTargetDuration(HLSStream *hls, QString &line)
1859 1860
     return RET_OK;
1860 1861
 }
1861 1862
 
1862  
-HLSStream *HLSRingBuffer::ParseStreamInformation(QString &line, QString &uri)
  1863
+HLSStream *HLSRingBuffer::ParseStreamInformation(const QString line, const QString uri) const
1863 1864
 {
1864 1865
     /*
1865 1866
      * #EXT-X-STREAM-INF:[attribute=value][,attribute=value]*
@@ -1900,7 +1901,7 @@ HLSStream *HLSRingBuffer::ParseStreamInformation(QString &line, QString &uri)
1900 1901
     return new HLSStream(id, bw, psz_uri);
1901 1902
 }
1902 1903
 
1903  
-int HLSRingBuffer::ParseMediaSequence(HLSStream *hls, QString &line)
  1904
+int HLSRingBuffer::ParseMediaSequence(HLSStream *hls, const QString line) const
1904 1905
 {
1905 1906
     /*
1906 1907
      * #EXT-X-MEDIA-SEQUENCE:<number>
@@ -1929,7 +1930,7 @@ int HLSRingBuffer::ParseMediaSequence(HLSStream *hls, QString &line)
1929 1930
 }
1930 1931
 
1931 1932
 
1932  
-int HLSRingBuffer::ParseKey(HLSStream *hls, QString &line)
  1933
+int HLSRingBuffer::ParseKey(HLSStream *hls, const QString line)
1933 1934
 {
1934 1935
     /*
1935 1936
      * #EXT-X-KEY:METHOD=<method>[,URI="<URI>"][,IV=<IV>]
@@ -1983,8 +1984,7 @@ int HLSRingBuffer::ParseKey(HLSStream *hls, QString &line)
1983 1984
         }
1984 1985
 
1985 1986
         /* Url is between quotes, remove them */
1986  
-        QString url = decoded_URI(uri.remove(QChar(QLatin1Char('"'))));
1987  
-        hls->SetKeyPath(url);
  1987
+        hls->SetKeyPath(decoded_URI(uri.remove(QChar(QLatin1Char('"')))));
1988 1988
 
1989 1989
         iv = ParseAttributes(line, "IV");
1990 1990
         if (!hls->SetAESIV(iv))
@@ -2009,7 +2009,7 @@ int HLSRingBuffer::ParseKey(HLSStream *hls, QString &line)
2009 2009
     return err;
2010 2010
 }
2011 2011
 
2012  
-int HLSRingBuffer::ParseProgramDateTime(HLSStream *hls, QString &line)
  2012
+int HLSRingBuffer::ParseProgramDateTime(HLSStream *hls, const QString line) const
2013 2013
 {
2014 2014
     /*
2015 2015
      * #EXT-X-PROGRAM-DATE-TIME:<YYYY-MM-DDThh:mm:ssZ>
@@ -2020,7 +2020,7 @@ int HLSRingBuffer::ParseProgramDateTime(HLSStream *hls, QString &line)
2020 2020
     return RET_OK;
2021 2021
 }
2022 2022
 
2023  
-int HLSRingBuffer::ParseAllowCache(HLSStream *hls, QString &line)
  2023
+int HLSRingBuffer::ParseAllowCache(HLSStream *hls, QString const line) const
2024 2024
 {
2025 2025
     /*
2026 2026
      * The EXT-X-ALLOW-CACHE tag indicates whether the client MAY or MUST
@@ -2044,7 +2044,7 @@ int HLSRingBuffer::ParseAllowCache(HLSStream *hls, QString &line)
2044 2044
     return RET_OK;
2045 2045
 }
2046 2046
 
2047  
-int HLSRingBuffer::ParseVersion(QString &line, int &version)
  2047
+int HLSRingBuffer::ParseVersion(const QString line, int &version) const
2048 2048
 {
2049 2049
     /*
2050 2050
      * The EXT-X-VERSION tag indicates the compatibility version of the
@@ -2075,7 +2075,7 @@ int HLSRingBuffer::ParseVersion(QString &line, int &version)
2075 2075
     return RET_OK;
2076 2076
 }
2077 2077
 
2078  
-int HLSRingBuffer::ParseEndList(HLSStream *hls)
  2078
+int HLSRingBuffer::ParseEndList(HLSStream *hls) const
2079 2079
 {
2080 2080
     /*
2081 2081
      * The EXT-X-ENDLIST tag indicates that no more media files will be
@@ -2087,7 +2087,7 @@ int HLSRingBuffer::ParseEndList(HLSStream *hls)
2087 2087
     return RET_OK;
2088 2088
 }
2089 2089
 
2090  
-int HLSRingBuffer::ParseDiscontinuity(HLSStream *hls, QString &line)
  2090
+int HLSRingBuffer::ParseDiscontinuity(HLSStream *hls, const QString line) const
2091 2091
 {
2092 2092
     /* Not handled, never seen so far */
2093 2093
     LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("#EXT-X-DISCONTINUITY %1").arg(line));
@@ -2171,8 +2171,7 @@ int HLSRingBuffer::ParseM3U8(const QByteArray *buffer, StreamsList *streams)
2171 2171
                 }
2172 2172
                 else
2173 2173
                 {
2174  
-                    QString url = decoded_URI(uri);
2175  
-                    HLSStream *hls = ParseStreamInformation(line, url);
  2174
+                    HLSStream *hls = ParseStreamInformation(line, decoded_URI(uri));
2176 2175
                     if (hls)
2177 2176
                     {
2178 2177
                         /* Download playlist file from server */
@@ -2268,8 +2267,7 @@ int HLSRingBuffer::ParseM3U8(const QByteArray *buffer, StreamsList *streams)
2268 2267
                 err = ParseEndList(hls);
2269 2268
             else if (!line.startsWith(QLatin1String("#")) && !line.isEmpty())
2270 2269
             {
2271  
-                QString url = decoded_URI(line);
2272  
-                hls->AddSegment(segment_duration, title, url);
  2270
+                hls->AddSegment(segment_duration, title, decoded_URI(line));
2273 2271
                 segment_duration = -1; /* reset duration */
2274 2272
                 title = "";
2275 2273
             }
@@ -2309,7 +2307,7 @@ int HLSRingBuffer::Prefetch(int count)
2309 2307
     return RET_OK;
2310 2308
 }
2311 2309
 
2312  
-void HLSRingBuffer::SanityCheck(HLSStream *hls, HLSSegment *segment)
  2310
+void HLSRingBuffer::SanityCheck(const HLSStream *hls, const HLSSegment *segment) const
2313 2311
 {
2314 2312
     bool live = hls->Live();
2315 2313
     /* sanity check */
@@ -2387,7 +2385,7 @@ int HLSRingBuffer::NumSegments(void) const
2387 2385
     return count;
2388 2386
 }
2389 2387
 
2390  
-int HLSRingBuffer::ChooseSegment(int stream)
  2388
+int HLSRingBuffer::ChooseSegment(int stream) const
2391 2389
 {
2392 2390
     /* Choose a segment to start which is no closer than
2393 2391
      * 3 times the target duration from the end of the playlist.
@@ -2396,7 +2394,7 @@ int HLSRingBuffer::ChooseSegment(int stream)
2396 2394
     int segid           = 0;
2397 2395
     int wanted_duration = 0;
2398 2396
     int count           = NumSegments();
2399  
-    int i = count - 1;
  2397
+    int i               = count - 1;
2400 2398
 
2401 2399
     HLSStream *hls = GetStream(stream);
2402 2400
     while(i >= 0)
@@ -2571,7 +2569,7 @@ bool HLSRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
2571 2569
     return true;
2572 2570
 }
2573 2571
 
2574  
-bool HLSRingBuffer::SaveToDisk(QString filename, int segstart, int segend)
  2572
+bool HLSRingBuffer::SaveToDisk(const QString filename, int segstart, int segend)
2575 2573
 {
2576 2574
     // download it all
2577 2575
     FILE *fp = fopen(filename.toAscii().constData(), "w");
44  mythtv/libs/libmythtv/HLS/httplivestreambuffer.h
@@ -57,8 +57,8 @@ class HLSRingBuffer : public RingBuffer
57 57
     virtual bool IsSeekingAllowed(void)     { return !m_error; }
58 58
     virtual bool IsBookmarkAllowed(void)    { return true; }
59 59
     static bool IsHTTPLiveStreaming(QByteArray *s);
60  
-    static bool TestForHTTPLiveStreaming(QString &filename);
61  
-    bool SaveToDisk(QString filename, int segstart = 0, int segend = -1);
  60
+    static bool TestForHTTPLiveStreaming(const QString filename);
  61
+    bool SaveToDisk(const QString filename, int segstart = 0, int segend = -1);
62 62
     int NumStreams(void) const;
63 63
     int Read(void *data, uint i_read) { return safe_read(data, i_read); }
64 64
     void Interrupt(void);
@@ -68,32 +68,32 @@ class HLSRingBuffer : public RingBuffer
68 68
     virtual int safe_read(void *data, uint i_read);
69 69
 
70 70
 private:
71  
-    void FreeStreamsList(QList<HLSStream*> *streams);
72  
-    HLSStream *GetStreamForSegment(int segid);
  71
+    void FreeStreamsList(QList<HLSStream*> *streams) const;
  72
+    HLSStream *GetStreamForSegment(int segid) const;
73 73
     HLSStream *GetStream(const int wanted, const StreamsList *streams = NULL) const;
74  
-    HLSStream *GetFirstStream(const StreamsList *streams = NULL);
75  
-    HLSStream *GetLastStream(const StreamsList *streams = NULL);
76  
-    HLSStream *FindStream(const HLSStream *hls_new, const StreamsList *streams = NULL);
  74
+    HLSStream *GetFirstStream(const StreamsList *streams = NULL) const;
  75
+    HLSStream *GetLastStream(const StreamsList *streams = NULL) const;
  76
+    HLSStream *FindStream(const HLSStream *hls_new, const StreamsList *streams = NULL) const;
77 77
     HLSStream *GetCurrentStream(void) const;
78  
-    QString ParseAttributes(QString &line, const char *attr);
79  
-    int ParseDecimalValue(QString &line, int &target);
80  
-    int ParseSegmentInformation(HLSStream *hls, QString &line,
81  
-                                int &duration, QString &title);
82  
-    int ParseTargetDuration(HLSStream *hls, QString &line);
83  
-    HLSStream *ParseStreamInformation(QString &line, QString &uri);
84  
-    int ParseMediaSequence(HLSStream *hls, QString &line);
85  
-    int ParseKey(HLSStream *hls, QString &line);
86  
-    int ParseProgramDateTime(HLSStream *hls, QString &line);
87  
-    int ParseAllowCache(HLSStream *hls, QString &line);
88  
-    int ParseVersion(QString &line, int &version);
89  
-    int ParseEndList(HLSStream *hls);
90  
-    int ParseDiscontinuity(HLSStream *hls, QString &line);
  78
+    QString ParseAttributes(const QString line, const char *attr) const;
  79
+    int ParseDecimalValue(const QString line, int &target) const;
  80
+    int ParseSegmentInformation(const HLSStream *hls, const QString line,
  81
+                                int &duration, QString &title) const;
  82
+    int ParseTargetDuration(HLSStream *hls, const QString line) const;
  83
+    HLSStream *ParseStreamInformation(const QString line, const QString uri) const;
  84
+    int ParseMediaSequence(HLSStream *hls, const QString line) const;
  85
+    int ParseKey(HLSStream *hls, const QString line);
  86
+    int ParseProgramDateTime(HLSStream *hls, const QString line) const;
  87
+    int ParseAllowCache(HLSStream *hls, const QString line) const;
  88
+    int ParseVersion(const QString line, int &version) const;
  89
+    int ParseEndList(HLSStream *hls) const;
  90
+    int ParseDiscontinuity(HLSStream *hls, const QString line) const;
91 91
     int ParseM3U8(const QByteArray *buffer, StreamsList *streams = NULL);
92 92
     int Prefetch(int count);
93  
-    void SanityCheck(HLSStream *hls, HLSSegment *segment);
  93
+    void SanityCheck(const HLSStream *hls, const HLSSegment *segment) const;
94 94
     HLSSegment *GetSegment(int segnum, int timeout = 1000);
95 95
     int NumSegments(void) const;
96  
-    int ChooseSegment(int stream);
  96
+    int ChooseSegment(int stream) const;
97 97
     int64_t SizeMedia(void) const;
98 98
     void WaitUntilBuffered(void);
99 99
     void SanitizeStreams(StreamsList *streams = NULL);

0 notes on commit 83872a3

Please sign in to comment.
Something went wrong with that request. Please try again.