1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* responselive.h: VDR on Smart TV plugin
*
* Copyright (C) 2013 T. Lohmar
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef __RESPONSE_LIVE_H__
#define __RESPONSE_LIVE_H__
#include "responsebase.h"
#include <cstdio>
#include <string>
#include <sys/time.h>
#include <vdr/ringbuffer.h>
#include <vdr/receiver.h>
//class cHttpResource;
using namespace std;
#if VDRVERSNUM < 10732
#define PCRFACTOR 300 // conversion from 27MHz PCR extension to 90kHz PCR base
inline int64_t TsGetPcr(const uchar *p)
{
if (TsHasAdaptationField(p)) {
if (p[4] >= 7 && (p[5] & TS_ADAPT_PCR)) {
return ((((int64_t)p[ 6]) << 25) |
(((int64_t)p[ 7]) << 17) |
(((int64_t)p[ 8]) << 9) |
(((int64_t)p[ 9]) << 1) |
(((int64_t)p[10]) >> 7)) * PCRFACTOR +
(((((int)p[10]) & 0x01) << 8) |
( ((int)p[11])));
}
}
return -1;
}
#endif
//class SmartTvServer;
class cPatPmtGenerator;
class cLiveRelay : public cReceiver {
public:
cLiveRelay(cChannel* channel, cDevice* device, string chan_id, int req_id, cHttpResource*);
~cLiveRelay();
// static cLiveRelay *create(string channel_id, int req_id, cHttpResource*);
// void addClient();
// int removeClient();
void setNotifRequired() { mNotifRequired = true; };
string mChannelId;
cRingBufferLinear *mRingBuffer;
pthread_mutex_t processedRingLock;
protected:
virtual void Activate(bool On);
virtual void Receive(uchar *Data, int Length);
void detachLiveRelay();
// cThread
// virtual void Action(void);
Log* mLog;
private:
// SmartTvServer *mFactory;
int mReqId;
cHttpResource* mRequest;
// int mNumClients;
// timeval mStartTime;
int mNotifFd;
bool mNotifRequired;
};
class cResponseLive : public cResponseBase {
public:
cResponseLive(cHttpResource*, string chan_id );
virtual ~cResponseLive();
int fillDataBlk();
int fillDataBlk_straight();
// int fillDataBlk_pcr();
// int fillDataBlk_iframe();
int fillDataBlk_duration();
int fillDataBlk_iPlusDuration();
bool findIFrame(char *b, int r);
bool bufferData(char *b, int r);
bool setLowerOffset(char *b, int r);
void justFillDataBlk(char *b, int r);
private:
bool InitRelay(string chan_id);
void WritePatPmt();
string mChannelId;
cLiveRelay* mRelay;
cPatPmtGenerator* mPatPmtGen;
bool mInStartPhase;
cFrameDetector* mFrameDetector;
int mVpid;
int mVtype;
int mPpid;
int mStartThreshold;
// Mode 4
int mCurOffset;
int mTuneInState;
int64_t mFirstPcr;
int mFirstPcrOffset;
int64_t mCurPcr;
int mCurPcrOffset;
int mNoFrames;
int mIFrameOffset;
int mLowerOffset;
};
#endif
|