@@ -10,6 +10,7 @@
extern "C" {
#include <transform.h>
+#include <ctools.h>
}
#include "common.h"
@@ -96,21 +97,25 @@
private:
bool active;
int video_fd;
+ int radio_fd;
cRingBufferLinear * tsBuffer;
cMutex * mutex;
static void WriteBuffer(unsigned char * buf, int count, void * p);
+ static void twrite_coque(uint8_t const *buf);
+ static void pes_filt_coque(p2p *p);
protected:
virtual void Action(void);
public:
- cPvrVideoReadThread(int VideoDevice, cRingBufferLinear * TsBuffer, cMutex * Mutex);
+ cPvrVideoReadThread(int VideoDevice, int RadioDevice, cRingBufferLinear * TsBuffer, cMutex * Mutex);
virtual ~cPvrVideoReadThread(void);
int PutData(const unsigned char * Data, int Count);
};
-cPvrVideoReadThread::cPvrVideoReadThread(int VideoDevice, cRingBufferLinear * TsBuffer, cMutex * Mutex)
+cPvrVideoReadThread::cPvrVideoReadThread(int VideoDevice, int RadioDevice, cRingBufferLinear * TsBuffer, cMutex * Mutex)
: active(false),
video_fd(VideoDevice),
+ radio_fd(RadioDevice),
tsBuffer(TsBuffer),
mutex(Mutex)
{
@@ -138,6 +143,27 @@
thread->PutData(buf, count);
}
+p2t_t p2t_coque;
+unsigned char buffer_coque[BUFFSIZE];
+int r_coque;
+
+void cPvrVideoReadThread::pes_filt_coque(p2p *p)
+{
+ int aux;
+
+ if ( p->cid == 0xc0)
+ {
+ aux = p->plength + 6;
+ memcpy(buffer_coque + r_coque, p->buf, aux);
+ r_coque += aux;
+ }
+}
+
+void cPvrVideoReadThread::twrite_coque(uint8_t const *buf)
+{
+ WriteBuffer((unsigned char *)buf, TS_SIZE, &p2t_coque);
+}
+
void cPvrVideoReadThread::Action(void)
{
active = true;
@@ -154,6 +180,7 @@
p2t.count1 = 0;
p2t.count0 = 0;
p2t.data = this;
+ init_p2t(&p2t_coque,twrite_coque);
while (active)
{
@@ -164,7 +191,17 @@
break;
}
if (r > 0)
- kpes_to_ts(&p2t, buffer, r); // PES -> TS
+ {
+ if (radio_fd >= 0)
+ {
+ r_coque = 0;
+ get_pes(buffer, r, &p2t, pes_filt_coque); // SOLO AUDIO
+ if (r_coque > 0)
+ pes_to_ts(buffer_coque, r_coque, kAudioPid, &p2t_coque); // PES -> TS
+ }
+ else
+ kpes_to_ts(&p2t, buffer, r); // PES -> TS
+ }
// cCondWait::SleepMs(1);
}
}
@@ -295,6 +332,7 @@
cPvrDevice::cPvrDevice(int DeviceNumber)
: video_fd(-1),
vbi_fd(-1),
+ radio_fd(-1),
frequency(-1),
vpid(-1),
apid(-1),
@@ -317,7 +355,7 @@
}
tsBuffer = new cRingBufferLinear(MEGABYTE(3), TS_SIZE, false, "PVRTS");
tsBuffer->SetTimeouts(100, 100);
- videoReadThread = new cPvrVideoReadThread(video_fd, tsBuffer, &mutex);
+ videoReadThread = new cPvrVideoReadThread(video_fd, radio_fd, tsBuffer, &mutex);
vbiReadThread = new cPvrVbiReadThread(vbi_fd, tsBuffer, &mutex);
SetVideoNorm(videoNormPAL);
SetCodec(aspect4by3, 6000, 256);
@@ -333,6 +371,8 @@
delete vbiReadThread;
delete tsBuffer;
close(vbi_fd);
+ if (radio_fd >= 0)
+ close (radio_fd);
close(video_fd);
}
@@ -434,7 +474,23 @@
memset(&vf, 0, sizeof(vf));
vf.tuner = 0;
vf.type = V4L2_TUNER_ANALOG_TV;
- vf.frequency = freq * 16 / 1000;
+ if (freq < 108000)
+ {
+ if (radio_fd == -1)
+ {
+ radio_fd = open ("/dev/radio",O_RDONLY);
+ }
+ vf.frequency = int((freq/1000.0f + .5/16) * 16);
+ }
+ else
+ {
+ if (radio_fd >=0)
+ {
+ close (radio_fd);
+ radio_fd = -1;
+ }
+ vf.frequency = freq * 16 / 1000;
+ }
if (IOCTL(video_fd, VIDIOC_S_FREQUENCY, &vf) != 0)
{
@@ -15,6 +15,7 @@
private:
int video_fd;
int vbi_fd;
+ int radio_fd;
int frequency;
int vpid;
int apid;
Sólo en pvrinput-0.0.1.radio: device.o
@@ -43,17 +43,17 @@
#define IVTV_SLICED_VPS (1 << 4)
struct ivtv_sliced_vbi_format {
- unsigned long service_set; /* one or more of the IVTV_SLICED_ defines */
- unsigned long packet_size; /* the size in bytes of the ivtv_sliced_data packet */
- unsigned long io_size; /* maximum number of bytes passed by one read() call */
- unsigned long reserved;
+ uint32_t service_set; /* one or more of the IVTV_SLICED_ defines */
+ uint32_t packet_size; /* the size in bytes of the ivtv_sliced_data packet */
+ uint32_t io_size; /* maximum number of bytes passed by one read() call */
+ uint32_t reserved;
};
/* This structure is the same as the proposed v4l2_sliced_data structure */
/* id is one of the VBI_SLICED_ flags. */
struct ivtv_sliced_data {
- unsigned long id;
- unsigned long line;
+ uint32_t id;
+ uint32_t line;
unsigned char data[0];
};