summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroskwon <kos@dev3>2014-06-23 09:24:54 (GMT)
committeroskwon <kos@dev3>2014-06-23 09:24:54 (GMT)
commit796c4be3eaac0bbad7173814fc8d03a29c9cd3d3 (patch)
tree7d85f98f5197157503b4f80b696afaf8ce59ba75
parenta2ed44d6148f2ac7d43c61a5eb878bc987e5d747 (diff)
Refactoring Mpeg class.
-rw-r--r--src/Mpeg.cpp16
-rw-r--r--src/Mpeg.h20
2 files changed, 18 insertions, 18 deletions
diff --git a/src/Mpeg.cpp b/src/Mpeg.cpp
index a1e74b4..431652e 100644
--- a/src/Mpeg.cpp
+++ b/src/Mpeg.cpp
@@ -73,7 +73,7 @@ void Mpeg::seek(HttpHeader &header)
else {
off_t position_offset;
if (!relative.empty()) {
- int dur = duration();
+ int dur = calc_length();
DEBUG("duration : %d", dur);
position_offset = (dur * Util::strtollu(relative)) / 100;
}
@@ -97,7 +97,7 @@ void Mpeg::seek(HttpHeader &header)
}
//----------------------------------------------------------------------
-off_t Mpeg::lseek(off_t offset, int whence)
+off_t Mpeg::seek_internal(off_t offset, int whence)
{
if (m_nrfiles < 2)
return ::lseek(get_fd(), offset, whence);
@@ -114,10 +114,10 @@ off_t Mpeg::lseek(off_t offset, int whence)
}
//----------------------------------------------------------------------
-ssize_t Mpeg::read(off_t offset, void *buf, size_t count)
+ssize_t Mpeg::read_internal(off_t offset, void *buf, size_t count)
{
if (offset != m_current_offset) {
- m_current_offset = this->lseek(offset, SEEK_SET);
+ m_current_offset = seek_internal(offset, SEEK_SET);
if (m_current_offset < 0) {
return m_current_offset;
}
@@ -176,7 +176,7 @@ void Mpeg::calc_begin()
void Mpeg::calc_end()
{
- off_t end = this->lseek(0, SEEK_END);
+ off_t end = seek_internal(0, SEEK_END);
if (llabs(end - m_last_filelength) > 1*1024*1024) {
m_last_filelength = end;
@@ -240,7 +240,7 @@ void Mpeg::take_samples()
m_samples_taken = 1;
m_samples.clear();
int retries=2;
- pts_t dummy = duration();
+ pts_t dummy = calc_length();
if (dummy <= 0)
return;
@@ -412,7 +412,7 @@ int Mpeg::get_pts(off_t &offset, pts_t &pts, int fixed)
while (left >= 188) {
unsigned char packet[188];
- if (this->read(offset, packet, 188) != 188) {
+ if (read_internal(offset, packet, 188) != 188) {
//break;
return -1;
}
@@ -534,7 +534,7 @@ int Mpeg::get_pts(off_t &offset, pts_t &pts, int fixed)
}
//----------------------------------------------------------------------
-int Mpeg::duration()
+int Mpeg::calc_length()
{
calc_begin(); calc_end();
if (!(m_begin_valid && m_end_valid))
diff --git a/src/Mpeg.h b/src/Mpeg.h
index 4bda815..9de8d06 100644
--- a/src/Mpeg.h
+++ b/src/Mpeg.h
@@ -29,30 +29,30 @@ private:
int m_begin_valid, m_end_valid, m_futile;
- std::map<pts_t, off_t> m_samples;
int m_samples_taken;
+ std::map<pts_t, off_t> m_samples;
void scan();
int switch_offset(off_t off);
void calc_end();
void calc_begin();
+ int calc_length();
+ int calc_bitrate();
int fix_pts(const off_t &offset, pts_t &now);
int get_pts(off_t &offset, pts_t &pts, int fixed);
-
- int duration();
- off_t lseek(off_t offset, int whence);
- ssize_t read(off_t offset, void *buf, size_t count);
-
int get_offset(off_t &offset, pts_t &pts, int marg);
- int take_sample(off_t off, pts_t &p);
+
void take_samples();
+ int take_sample(off_t off, pts_t &p);
+
+ off_t seek_internal(off_t offset, int whence);
+ ssize_t read_internal(off_t offset, void *buf, size_t count);
- int calc_bitrate();
public:
- Mpeg(std::string file, bool request_time_seek) throw (trap)
- : MpegTS(file, request_time_seek)
+ Mpeg(std::string filename, bool request_time_seek) throw (trap)
+ : MpegTS(filename, request_time_seek)
{
m_current_offset = m_base_offset = m_last_offset = 0;
m_splitsize = m_nrfiles = m_current_file = m_totallength = 0;