368adb70b7ce4a239b73a429fa7e8425a7c0cfdf
[enigma2.git] / lib / service / servicedvbrecord.cpp
1 #include <lib/service/servicedvbrecord.h>
2 #include <lib/base/eerror.h>
3
4
5 DEFINE_REF(eDVBServiceRecord);
6
7 eDVBServiceRecord::eDVBServiceRecord(const eServiceReferenceDVB &ref): m_ref(ref)
8 {
9         CONNECT(m_service_handler.serviceEvent, eDVBServiceRecord::serviceEvent);
10 }
11
12 void eDVBServiceRecord::serviceEvent(int event)
13 {
14         eDebug("service event %d", event);
15         switch (event)
16         {
17         case eDVBServicePMTHandler::eventTuned:
18         {
19                 eDebug("tuned..");
20                 break;
21         }
22         case eDVBServicePMTHandler::eventNewProgramInfo:
23         {
24                 int vpid = -1, apid = -1, pcrpid = -1;
25                 eDVBServicePMTHandler::program program;
26                 if (m_service_handler.getProgramInfo(program))
27                         eDebug("getting program info failed.");
28                 else
29                 {
30                         eDebugNoNewLine("RECORD: have %d video stream(s)", program.videoStreams.size());
31                         if (!program.videoStreams.empty())
32                         {
33                                 eDebugNoNewLine(" (");
34                                 for (std::vector<eDVBServicePMTHandler::videoStream>::const_iterator
35                                         i(program.videoStreams.begin()); 
36                                         i != program.videoStreams.end(); ++i)
37                                 {
38                                         if (vpid == -1)
39                                                 vpid = i->pid;
40                                         if (i != program.videoStreams.begin())
41                                                 eDebugNoNewLine(", ");
42                                         eDebugNoNewLine("%04x", i->pid);
43                                 }
44                                 eDebugNoNewLine(")");
45                         }
46                         eDebugNoNewLine(", and %d audio stream(s)", program.audioStreams.size());
47                         if (!program.audioStreams.empty())
48                         {
49                                 eDebugNoNewLine(" (");
50                                 for (std::vector<eDVBServicePMTHandler::audioStream>::const_iterator
51                                         i(program.audioStreams.begin()); 
52                                         i != program.audioStreams.end(); ++i)
53                                 {
54                                         if (apid == -1)
55                                                 apid = i->pid;
56                                         if (i != program.audioStreams.begin())
57                                                 eDebugNoNewLine(", ");
58                                         eDebugNoNewLine("%04x", i->pid);
59                                 }
60                                 eDebugNoNewLine(")");
61                         }
62                         eDebug(", and the pcr pid is %04x", program.pcrPid);
63                         if (program.pcrPid != 0x1fff)
64                                 pcrpid = program.pcrPid;
65                 }
66                 
67                                 // notify record thread...              
68                 break;
69         }
70         }
71 }
72
73 RESULT eDVBServiceRecord::start()
74 {
75         eDebug("starting recording..");
76         return m_service_handler.tune(m_ref);
77 }
78
79 RESULT eDVBServiceRecord::stop()
80 {
81         eDebug("stop recording!!");
82         return 0;
83 }
84