PDA

View Full Version : video-streaming MythTV



gorka_sm
24th April 2011, 20:51
Hello I have implemented a video streaming client based on a Qt MythUI client. There is a server implemented in JAVA for sending images an frames and threre is also other client developed in Qt for reveiving all the images and representing them . The code of the client is developed in a class called NetworkControl and it is the following :


void NetworkControl::aceptar_conexiones()
{

QTcpSocket *soket = new QTcpSocket(this);
const QString direc ="xxxxxxxxxx";
quint16 port = 4445;
soket->connectToHOst(direc,port)
connect(soket,SIGNAL(readyRead()),this,SLOT(leerca racter()))

}





void NetworkControl::leerCaracter()
{

QTcpSocket *socket (QTcpSocket *)sender();
QBYteArray *b1 = socket->readAll();

QImage ax= new QImage("xxxxxxxx");

ax->Load(b1);

}

I am working in a Mythtv system ( http://www.mythtv.org/wiki/User_Manual:Initial_Installation ) . I have the following doubts:

1 - How to obtain a QByteArray from a a QImage ( is ax->Load(b1) the correct way of obtaining it ?)
2 - I have to represent the QImage on a screen. I am working with the class MythImage ( http://www.cuymedia.net/mythtv-0.20/mythimage_8h-source.html ) y MythUIImage ( http://cuymedia.net/mythtv-trunk/myth
uiimage_8h-source.html ) .
How to convert from QImage to MythImage ? How to convert from MythImage to MythUIImage ?
3- Is there other way of representing images in Mythtv ?
Thanks
Gorka

high_flyer
27th April 2011, 09:39
1 - How to obtain a QByteArray from a a QImage

QByteArray baImage(image.bits(),iImageByteSize);

How to convert from QImage to MythImage ?
Since MythImage subclasses QImage, you could use for example loadFromData() or fromData() and give it QImage::bits() as input.

gorsanmo
27th April 2011, 10:19
Hello :
I obtain the QImage using the following code :



QTcpSocket *socket (QTcpSocket *)sender();
QBYteArray *b1 = socket->readAll();
QImage ax= new QImage("xxxxxxxx");
ax->Load(b1);


NOw I have two questions

1) When I asked you how to pass from a QImage to a MythIMage you told me :


"Since MythImage subclasses QImage, you could use for example loadFromData() or fromData() and give it QImage::bis() as input "
¿ What does QImage::bis() mean ?

2) In JAVA I implement the following QTcpServer for sending Images :



ServerSocket servidor = new ServerSocket(4445);
Socket conexion = null;
salida = new Vector<ObjectOutputStream>();

// iniciar la captura desde la webcam
CaptureStream captureStream = iniciarCaptura();

conexion = servidor.accept();
salida.add(new ObjectOutputStream(conexion .getOutputStream()));

Where iniciarcaptura() is the following method :



private CaptureStream iniciarCaptura() throws IOException,
CaptureException
{
CaptureStream captureStream = null;
List list = system.getCaptureDeviceInfoList();
for (int i = 0; i < list.size(); ++i)
{
CaptureDeviceInfo info = (CaptureDeviceInfo)list.get(i);

ptureStream = system.openCaptureDeviceStream(info.getDeviceID()) ;

List<VideoFormat> ls = captureStream.enumVideoFormats();

captureStream.setVideoFormat(ls.get(0));

captureStream.setObserver(new MyCaptureObserver());

break;
}

return captureStream;
}


The question is

Is
QTcpSocket *socket (QTcpSocket *)sender();
QBYteArray *b1 = socket->readAll();
the best way of reading Images in the receptor ?

Thanks
Gorka

high_flyer
27th April 2011, 11:15
¿ What does QImage::bis() mean ?
Read the docs.
I had a typo it should be QImage::bits().

the best way of reading Images in the receptor ?

depends on the way you evaluate what "best" is.
It is a valid way for sure.