I am trying to stream compressed raw framebuffer data to my Client application on the PC, from my Server service on Android. On the PC I want to display this raw data as streamed video in my Client's view, giving real-time view of the Android device's screen. I know how to get the resolution of the screen, but not the Bits-Per-Pixel(BPP) nor the Pixel's Color Format of the raw data programmatically at Android(Server) side. Please help.
All I could find over the Internet is native code. But I really wish to maintain the application as Java defined as possible.
From FBIOGET_VSCREENINFO over ioctl get BPP(bits-per-pixel) as follows
int main () {
int fbfd;
struct fb_var_screeninfo variable_info;
fbfd=open("/dev/fb0", O_RDWR);
//in real life, check every ioctl if it returns -1
ioctl (fbfd, FBIOGET_VSCREENINFO, &variable_info);
//This is the required BPP value
switch(variable_info.bits_per_pixel) {
case 16: //pixel format is RGB_565
break;
case 24: //pixel format is RGB_888
break;
case 32: //pixel format is RGBX_8888
break;
}
}
Finally figured out how to determine
Size of the framebuffer & individual frames
int main() {
//Structs defined in "linux/fb.h"
struct fb_var_screeninfo vscreeninfo;
struct fb_fix_screeninfo fscreeninfo;
//Open the framebuffer
fbfd=open("/dev/graphics/fb0",O_RDONLY);
if(fbfd==-1) {
__android_log_print(ANDROID_LOG_ERROR,ERR,
"Could not open framebuffer fbfd=%d errno=%d",fbfd,errno);
return errno;
}
//Fetch variable screen info
ioct=ioctl(fbfd,FBIOGET_VSCREENINFO,&vscreeninfo);
if(ioct==-1) {
__android_log_print(ANDROID_LOG_ERROR,ERR,
"VSCREEN-IOCTL failed ioct=%d errno=%d",ioct,errno);
return errno;
}
//Fetch fixed screen info
ioct=ioctl(fbfd,FBIOGET_FSCREENINFO,&fscreeninfo);
if(ioct==-1) {
__android_log_print(ANDROID_LOG_ERROR,ERR,
"FSCREEN-IOCTL failed ioct=%d errno=%d",ioct,errno);
return errno;
}
close(ioct);
/**********************************VSCREEN DATA************************************/
printf("\nVscreen Info:-\n");
printf(" Xres = %4ld | Yres = %4ld\n",vscreeninfo.xres,vscreeninfo.yres);
printf(" BPP = %4ld | Height = %4ld | Width = %4ld\n",vscreeninfo.bits_per_pixel,
vscreeninfo.height,
vscreeninfo.width);
printf(" Xres_V = %4ld | Yres_V = %4ld\n",vscreeninfo.height,vscreeninfo.width);
printf(" Pixel format : RGBX_%ld%ld%ld%ld\n",vscreeninfo.red.length,
vscreeninfo.green.length,
vscreeninfo.blue.length,
vscreeninfo.transp.length);
printf(" Begin of bitfields(Byte ordering):-\n"); //In my case :
printf(" Red : %ld\n",vscreeninfo.red.offset); //Red : 16
printf(" Blue : %ld\n",vscreeninfo.blue.offset); //Blue : 0
printf(" Green : %ld\n",vscreeninfo.green.offset); //Green : 8
printf(" Transp : %ld\n",vscreeninfo.transp.offset); //Transp : 24
//Hence orientation is : BGRT => (BGR4)RGB32 packed format
/********************************~VSCREEN DATA************************************/
/*********************************FSCREEN DATA************************************/
printf("\nFscreen Info:-\n");
printf(" Device ID : %s\n",fscreeninfo.id);
printf(" Start of FB physical address : %ld\n",fscreeninfo.smem_start);
printf(" Length of FB : %ld\n",fscreeninfo.smem_len); //Size of framebuffer in bytes
printf(" Length of Line : %ld\n",fscreeninfo.line_length);
printf(" Start of MMIO physical address : %ld\n",fscreeninfo.mmio_start);
printf(" Length of MMIO : %ld\n",fscreeninfo.mmio_len);
/********************************~FSCREEN DATA************************************/
close(fbfd);
return 0;
}
References :-