1 /*******************************************************************************
2 VLC Player Plugin by A. Lätsch 2007
4 This is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
8 ********************************************************************************/
13 #include <lib/base/ioprio.h>
14 #include <lib/base/message.h>
15 #include <lib/service/iservice.h>
16 #include <lib/dvb/dvb.h>
18 class eStaticServiceTSInfo;
20 class eServiceFactoryTS: public iServiceHandler
22 DECLARE_REF(eServiceFactoryTS);
25 virtual ~eServiceFactoryTS();
29 RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
30 RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
31 RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
32 RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
33 RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
37 DECLARE_REF(TSAudioInfo);
42 std::string language; /* iso639 */
43 std::string description;
45 std::vector<StreamInfo> audioStreams;
46 void addAudio(int pid, std::string lang, std::string desc, int type);
51 class eServiceTS: public iPlayableService, public iPauseableService,
52 public iServiceInformation, public iSeekableService,
53 public iAudioTrackSelection, public iAudioChannelSelection, public Object
55 DECLARE_REF(eServiceTS);
57 virtual ~eServiceTS();
60 RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
63 RESULT pause(ePtr<iPauseableService> &ptr);
64 RESULT seek(ePtr<iSeekableService> &ptr);
65 RESULT info(ePtr<iServiceInformation>&);
68 RESULT setTarget(int target) { return -1; };
69 RESULT setSlowMotion(int ratio) { return -1; };
70 RESULT setFastForward(int ratio) { return -1; };
71 RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = this; return 0; };
72 RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = this; return 0; };
73 RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; };
74 RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; };
75 RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; };
76 RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; };
77 RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; };
78 RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; };
79 RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; };
80 RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; };
81 RESULT streamed(ePtr<iStreamedService> &ptr) { ptr = 0; return -1; };
82 RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; };
89 RESULT getLength(pts_t &SWIG_OUTPUT);
90 RESULT seekTo(pts_t to);
91 RESULT seekRelative(int direction, pts_t to);
92 RESULT getPlayPosition(pts_t &SWIG_OUTPUT);
93 RESULT setTrickmode(int trick);
94 RESULT isCurrentlySeekable();
96 // iServiceInformation
97 RESULT getName(std::string &name);
99 std::string getInfoString(int w);
101 // iAudioTrackSelection
102 int getNumberOfTracks();
103 RESULT selectTrack(unsigned int i);
104 SWIG_VOID(RESULT) getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
105 int getCurrentTrack();
107 // iAudioChannelSelection
108 int getCurrentChannel() { return iAudioChannelSelection_ENUMS::STEREO; };
109 RESULT selectChannel(int i) { return 0; };
112 friend class eServiceFactoryTS;
113 std::string m_filename;
116 ePtr<iDVBDemux> m_decodedemux;
117 ePtr<iTSMPEGDecoder> m_decoder;
118 ePtr<eStreamThread> m_streamthread;
119 ePtr<TSAudioInfo> m_audioInfo;
121 eServiceTS(const eServiceReference &url);
122 int openHttpConnection(std::string url);
124 Signal2<void,iPlayableService*,int> m_event;
127 stIdle, stRunning, stStopped
130 eFixedMessagePump<int> m_pump;
131 void recv_event(int evt);
132 void setAudioPid(int pid, int type);
135 class eStreamThread: public eThread, public Object {
136 DECLARE_REF(eStreamThread);
139 virtual ~eStreamThread();
140 void start(int srcfd, int destfd);
143 virtual void thread();
144 virtual void thread_finished();
146 RESULT getAudioInfo(ePtr<TSAudioInfo> &ptr);
148 enum { evtEOS, evtSOS, evtReadError, evtWriteError, evtUser, evtStreamInfo };
149 Signal1<void,int> m_event;
152 int m_srcfd, m_destfd;
153 ePtr<TSAudioInfo> m_audioInfo;
154 eFixedMessagePump<int> m_messagepump;
155 void recvEvent(const int &evt);
156 bool scanAudioInfo(unsigned char buf[], int len);
157 std::string getDescriptor(unsigned char buf[], int buflen, int type);