summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkos <kos@dev3>2013-11-04 10:18:48 (GMT)
committerkos <kos@dev3>2013-11-04 10:18:48 (GMT)
commitbfd3687dc12aef8e90c88a9dc45bdbfb9ed60608 (patch)
treeb9f2ade6926dfe7179adb092f1f556c05851041d
parent4f510c2c80a85a14ff2d0ce16f1323a6a66f0366 (diff)
added setting pmt-pid at transcodingdevice.
-rw-r--r--src/eParser.cpp13
-rw-r--r--src/eParser.h2
-rw-r--r--src/eTransCodingDevice.cpp41
-rw-r--r--src/eTransCodingDevice.h1
-rw-r--r--src/main.cpp8
5 files changed, 52 insertions, 13 deletions
diff --git a/src/eParser.cpp b/src/eParser.cpp
index 43b3466..536554e 100644
--- a/src/eParser.cpp
+++ b/src/eParser.cpp
@@ -172,7 +172,7 @@ unsigned long StripPid(std::string aData, std::string& aOutType)
//-------------------------------------------------------------------------------
bool eParser::LiveStreamPid(std::string aData, std::vector<unsigned long>& aPidList,
- int& aDemuxId, int& aVideoPid, int& aAudioPid, std::string& aWWWAuth)
+ int& aDemuxId, int& aVideoPid, int& aAudioPid, int& aPmtPid, std::string& aWWWAuth)
{
int state = 0;
int responsecode = 0;
@@ -234,6 +234,11 @@ bool eParser::LiveStreamPid(std::string aData, std::vector<unsigned long>& aPidL
aAudioPid = pid;
}
}
+ if(aPmtPid == 0) {
+ if(strcmp(pidtype.c_str(), "pmt") == 0) {
+ aPmtPid = pid;
+ }
+ }
if(!eDemuxPumpThread::ExistPid(aPidList, pid)) {
aPidList.push_back(pid);
@@ -241,9 +246,9 @@ bool eParser::LiveStreamPid(std::string aData, std::vector<unsigned long>& aPidL
#ifdef DEBUG_LOG
LOG("pid : %s [%04X]", pidtokens[ii].c_str(), pid);
#endif
-// if(aAudioPid && aVideoPid) {
-// return true;
-// }
+ if(aAudioPid && aVideoPid) {
+ return true;
+ }
}
}
}
diff --git a/src/eParser.h b/src/eParser.h
index 60581cd..01a0dbc 100644
--- a/src/eParser.h
+++ b/src/eParser.h
@@ -21,7 +21,7 @@ public:
static void FileName(char* aRequest, char* aHttp, std::string& aOutData);
static bool MetaData(std::string aMediaFileName, int& aVideoPid, int& aAudioPid);
static bool LiveStreamPid(std::string aData, std::vector<unsigned long>& aPidList,
- int& aDemuxId, int& aVideoPid, int& aAudioPid, std::string& aWWWAuth);
+ int& aDemuxId, int& aVideoPid, int& aAudioPid, int& aPmtPid, std::string& aWWWAuth);
static std::string ServiceRef(std::string aData, std::string aAuthorization);
};
//-------------------------------------------------------------------------------
diff --git a/src/eTransCodingDevice.cpp b/src/eTransCodingDevice.cpp
index 280ba73..5ff7e42 100644
--- a/src/eTransCodingDevice.cpp
+++ b/src/eTransCodingDevice.cpp
@@ -19,6 +19,12 @@
//#define LOG(X,...) { do{}while(0); }
#endif
+#define IOCTL_OPCODE_SET_VPID 1
+#define IOCTL_OPCODE_SET_APID 2
+#define IOCTL_OPCODE_SET_PMTPID 3
+#define IOCTL_OPCODE_START_TRANSCODING 100
+#define IOCTL_OPCODE_STOP_TRANSCODING 200
+
eTransCodingDevice::eTransCodingDevice()
: mDeviceFd(0)
{
@@ -66,13 +72,13 @@ int eTransCodingDevice::GetDeviceFd()
bool eTransCodingDevice::SetStreamPid(int aVideoPid, int aAudioPid)
{
- if(ioctl(mDeviceFd, 1, aVideoPid) < 0) {
+ if(ioctl(mDeviceFd, IOCTL_OPCODE_SET_VPID, aVideoPid) < 0) {
#ifdef DEBUG_LOG
LOG("setting stream video pid failed.");
#endif
return false;
}
- if(ioctl(mDeviceFd, 2, aAudioPid) < 0) {
+ if(ioctl(mDeviceFd, IOCTL_OPCODE_SET_APID, aAudioPid) < 0) {
#ifdef DEBUG_LOG
LOG("setting stream audio pid failed.");
#endif
@@ -85,9 +91,36 @@ bool eTransCodingDevice::SetStreamPid(int aVideoPid, int aAudioPid)
}
//-------------------------------------------------------------------------------
+bool eTransCodingDevice::SetStreamPid(int aVideoPid, int aAudioPid, int aPmtPid)
+{
+ if(ioctl(mDeviceFd, IOCTL_OPCODE_SET_VPID, aVideoPid) < 0) {
+#ifdef DEBUG_LOG
+ LOG("setting stream video pid failed.");
+#endif
+ return false;
+ }
+ if(ioctl(mDeviceFd, IOCTL_OPCODE_SET_APID, aAudioPid) < 0) {
+#ifdef DEBUG_LOG
+ LOG("setting stream audio pid failed.");
+#endif
+ return false;
+ }
+ if(ioctl(mDeviceFd, IOCTL_OPCODE_SET_PMTPID, aPmtPid) < 0) {
+#ifdef DEBUG_LOG
+ LOG("setting stream pmt pid failed.");
+#endif
+ return false;
+ }
+#ifdef DEBUG_LOG
+ LOG("setting stream pid ok.");
+#endif
+ return true;
+}
+//-------------------------------------------------------------------------------
+
bool eTransCodingDevice::StartTranscoding()
{
- if(ioctl(mDeviceFd, 100, 0) < 0) {
+ if(ioctl(mDeviceFd, IOCTL_OPCODE_START_TRANSCODING, 0) < 0) {
#ifdef DEBUG_LOG
LOG("start transcoding failed.");
#endif
@@ -102,6 +135,6 @@ bool eTransCodingDevice::StartTranscoding()
void eTransCodingDevice::StopTranscoding()
{
- ioctl(mDeviceFd, 200, 0);
+ ioctl(mDeviceFd, IOCTL_OPCODE_STOP_TRANSCODING, 0);
}
//-------------------------------------------------------------------------------
diff --git a/src/eTransCodingDevice.h b/src/eTransCodingDevice.h
index fbc1fcf..45b059d 100644
--- a/src/eTransCodingDevice.h
+++ b/src/eTransCodingDevice.h
@@ -22,6 +22,7 @@ public:
int GetDeviceFd();
bool SetStreamPid(int aVideoPid, int aAudioPid);
+ bool SetStreamPid(int aVideoPid, int aAudioPid, int aPmtPid);
bool StartTranscoding();
void StopTranscoding();
diff --git a/src/main.cpp b/src/main.cpp
index f029591..0a8a25b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -60,7 +60,7 @@ GET /file?file=/hdd/movie/20131023%201005%20-%20DW%20-%20Germany%20Today.ts HTTP
int main(int argc, char** argv)
{
char request[MAX_LINE_LENGTH] = {0};
- int videopid = 0, audiopid = 0;
+ int videopid = 0, audiopid = 0, pmtid = 0;
signal(SIGINT, SignalHandler);
@@ -112,9 +112,9 @@ int main(int argc, char** argv)
int demuxno = 0;
std::string wwwauthenticate = "";
std::vector<unsigned long> pidlist;
- ispidseted = eParser::LiveStreamPid(responsedata, pidlist, demuxno, videopid, audiopid, wwwauthenticate);
+ ispidseted = eParser::LiveStreamPid(responsedata, pidlist, demuxno, videopid, audiopid, pmtid, wwwauthenticate);
if(ispidseted) {
- if(transcoding.SetStreamPid(videopid, audiopid) == false) {
+ if(transcoding.SetStreamPid(videopid, audiopid, pmtid) == false) {
RETURN_ERR_502("Pid setting failed.");
}
} else {
@@ -125,7 +125,7 @@ int main(int argc, char** argv)
}
#ifdef DEBUG_LOG
- LOG("stream pids parsing result : %d, video : %d, audio : %d, pids size : [%d]", ispidseted, videopid, audiopid, pidlist.size());
+ LOG("stream pids parsing result : %d, video : %d, audio : %d, pmt : %d, pids size : [%d]", ispidseted, videopid, audiopid, pmtid, pidlist.size());
for(int j = 0; j < pidlist.size(); ++j) {
LOG("saved pid : [%x]", pidlist[j]);
}