[CVS] avview Makefile.am,1.18,1.19 avview.scp,1.117,1.118 km.scp,1.1,1.2 vbi.c,1.5,1.6 vbi.scp,1.1,1
Status: Beta
Brought to you by:
volodya
From: <gat...@li...> - 2003-02-22 06:57:00
|
Update of /cvsroot/gatos/avview In directory sc8-pr-cvs1:/tmp/cvs-serv23603 Modified Files: Makefile.am avview.scp km.scp vbi.c vbi.scp Log Message: Integrating CC support into AVview. Index: Makefile.am =================================================================== RCS file: /cvsroot/gatos/avview/Makefile.am,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Makefile.am 15 Feb 2003 02:23:50 -0000 1.18 +++ Makefile.am 22 Feb 2003 06:56:56 -0000 1.19 @@ -20,7 +20,7 @@ nodist_scp_DATA = start_avview.desktop dist_scp_DATA = alsa.scp bindings.scp ffmpeg.scp themes.scp video_device.scp \ - alsa_mixer.scp channel_scan.scp km.scp tree.scp xv.scp \ + alsa_mixer.scp channel_scan.scp km.scp tree.scp xv.scp vbi.scp \ avview.scp diag.scp setup.scp v4l.scp xmisc.scp avview.modmap \ avview-16x16.ppm avview-control-16x16.ppm avview-48x48.png start_avview.desktop.in \ README INSTALL Index: avview.scp =================================================================== RCS file: /cvsroot/gatos/avview/avview.scp,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -r1.117 -r1.118 --- avview.scp 12 Jan 2003 07:59:28 -0000 1.117 +++ avview.scp 22 Feb 2003 06:56:56 -0000 1.118 @@ -58,7 +58,7 @@ foreach file {xmisc.scp tree.scp setup.scp themes.scp alsa.scp v4l.scp xv.scp channel_scan.scp ffmpeg.scp - video_device.scp diag.scp bindings.scp} { + video_device.scp diag.scp bindings.scp vbi.scp km.scp} { source $avview_directory/$file } @@ -77,7 +77,7 @@ . configure -width 320 -height 240 -background black #frame .video -background #102030 -eval frame .video [get_settings .video AVview] +eval canvas .video [get_settings .video AVview] .video configure -borderwidth 0 place .video -relx 0.0 -rely 0.0 -relwidth 1.0 -relheight 1.0 -anchor nw Index: km.scp =================================================================== RCS file: /cvsroot/gatos/avview/km.scp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- km.scp 8 Jun 2002 00:15:13 -0000 1.1 +++ km.scp 22 Feb 2003 06:56:56 -0000 1.2 @@ -18,4 +18,38 @@ puts "$r" } -get_km_status "/proc/km/control0" +proc find_km_device { location_id } { +puts "Looking for km device that corresponds to $location_id" +set km_devs [list ] +catch { + set km_devs [split [exec ls -1 /proc/km] "\n"] + } +puts "km_devs=$km_devs" +set LOCATION_ID "" +foreach file $km_devs { + if { ! [regexp {^control} $file] } { continue } + set attrs [list ] + catch { + set FILE [open /proc/km/$file "w+"] + fconfigure $FILE -buffersize 65536 + puts -nonewline $FILE "STATUS\n" + flush $FILE + while {1} { + gets $FILE line + puts "read line=$line" + if { [regexp {^(.*)=(.*)} $line {} var value] } { + set $var $value + lappend attrs $var $value + } + if { [regexp {END_STATUS} $line] } { break } + } + } + if { $LOCATION_ID == $location_id } { + return [list $file $attrs] + } + } +} + +after 1000 { + puts "[find_km_device [get_location_id]]" + } Index: vbi.c =================================================================== RCS file: /cvsroot/gatos/avview/vbi.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- vbi.c 16 Feb 2003 07:38:12 -0000 1.5 +++ vbi.c 22 Feb 2003 06:56:56 -0000 1.6 @@ -395,7 +395,7 @@ } pageno=atoi(argv[2]); if((pageno<1)||(pageno>8)){ - Tcl_AppendResult(interp,"ERROR: vbi_draw_CC_page no such handle", NULL); + Tcl_AppendResult(interp,"ERROR: vbi_draw_CC_page no such page", NULL); return TCL_ERROR; } ph=Tk_FindPhoto(interp, argv[3]); @@ -484,6 +484,229 @@ return TCL_OK; } +char *vbi_char_attr(vbi_char *c) +{ +char s[200]; +int i; + +i=0; +if(c->underline){ + s[i]='u'; + i++; + } +if(c->bold){ + s[i]='b'; + i++; + } +if(c->italic){ + s[i]='i'; + i++; + } +s[i]='-'; +i++; +if(c->flash){ + s[i]='f'; + i++; + } +if(c->conceal){ + s[i]='c'; + i++; + } +s[i]='-'; +i++; +switch(c->size){ + case VBI_DOUBLE_WIDTH: + i+=sprintf(s+i,"double_width-"); + break; + case VBI_DOUBLE_HEIGHT: + i+=sprintf(s+i,"double_height-"); + break; + case VBI_DOUBLE_SIZE: + i+=sprintf(s+i,"double_size-"); + break; + case VBI_OVER_TOP: + i+=sprintf(s+i,"over_top-"); + break; + case VBI_OVER_BOTTOM: + i+=sprintf(s+i,"over_bottom-"); + break; + case VBI_DOUBLE_HEIGHT2: + i+=sprintf(s+i,"double_h2-"); + break; + case VBI_DOUBLE_SIZE2: + i+=sprintf(s+i,"double_s2-"); + break; + case VBI_NORMAL_SIZE: + default: + i+=sprintf(s+i,"normal-"); + break; + } +switch(c->opacity){ + case VBI_TRANSPARENT_SPACE: + i+=sprintf(s+i,"space-"); + break; + case VBI_TRANSPARENT_FULL: + i+=sprintf(s+i,"full-"); + break; + case VBI_SEMI_TRANSPARENT: + i+=sprintf(s+i,"semi-"); + break; + case VBI_OPAQUE: + i+=sprintf(s+i,"opaque-"); + break; + } +switch(c->foreground){ + case VBI_RED: + i+=sprintf(s+i,"red-"); + break; + case VBI_GREEN: + i+=sprintf(s+i,"green-"); + break; + case VBI_YELLOW: + i+=sprintf(s+i,"yellow-"); + break; + case VBI_BLUE: + i+=sprintf(s+i,"blue-"); + break; + case VBI_MAGENTA: + i+=sprintf(s+i,"magenta-"); + break; + case VBI_CYAN: + i+=sprintf(s+i,"cyan-"); + break; + case VBI_WHITE: + i+=sprintf(s+i,"white-"); + break; + case VBI_BLACK: + default: + i+=sprintf(s+i,"black-"); + break; + } +switch(c->background){ + case VBI_RED: + i+=sprintf(s+i,"red-"); + break; + case VBI_GREEN: + i+=sprintf(s+i,"green-"); + break; + case VBI_YELLOW: + i+=sprintf(s+i,"yellow-"); + break; + case VBI_BLUE: + i+=sprintf(s+i,"blue-"); + break; + case VBI_MAGENTA: + i+=sprintf(s+i,"magenta-"); + break; + case VBI_CYAN: + i+=sprintf(s+i,"cyan-"); + break; + case VBI_WHITE: + i+=sprintf(s+i,"white-"); + break; + case VBI_BLACK: + default: + i+=sprintf(s+i,"black-"); + break; + } +s[i]=0; +return strdup(s); +} + +int vbi_get_cc_page(ClientData client_data,Tcl_Interp* interp,int argc,const char *argv[]) +{ +long i,k,l; +VBI_DATA *data; +int pageno; +vbi_page page; +vbi_char *c; +char *vca_previous, *vca_current; +Tcl_UniChar s[1000]; +int s_count; +Tcl_Obj *lines; +Tcl_Obj *a; +int prev_x, prev_y; + +Tcl_ResetResult(interp); + +if(argc<3){ + Tcl_AppendResult(interp,"ERROR: vbi_new_channel requires two arguments", NULL); + return TCL_ERROR; + } + +i=lookup_string(vbi_sc, argv[1]); +if(i<0){ + Tcl_AppendResult(interp,"ERROR: vbi_draw_CC_page no such handle", NULL); + return TCL_ERROR; + } +data=(VBI_DATA *)vbi_sc->data[i]; +if(data==NULL){ + Tcl_AppendResult(interp,"ERROR: vbi_draw_CC_page no such handle", NULL); + return TCL_ERROR; + } +pageno=atoi(argv[2]); +if((pageno<1)||(pageno>8)){ + Tcl_AppendResult(interp,"ERROR: vbi_draw_CC_page no such page", NULL); + return TCL_ERROR; + } +pthread_mutex_lock(&(data->mutex)); +vbi_fetch_cc_page(data->dec, &page, pageno, FALSE); +pthread_mutex_unlock(&(data->mutex)); + +vca_previous=strdup(""); +vca_current=NULL; +lines=Tcl_NewListObj(0,NULL); +Tcl_ListObjAppendElement(interp, lines, Tcl_NewIntObj(page.columns)); +Tcl_ListObjAppendElement(interp, lines, Tcl_NewIntObj(page.rows)); +a=NULL; +prev_x=-1; +prev_y=-1; +s_count=0; +for(k=0;k<page.rows;k++){ + for(l=0;l<page.columns;l++){ + c=&(page.text[l+k*page.columns]); + vca_current=vbi_char_attr(c); + if((c->opacity!=VBI_TRANSPARENT_SPACE) && !strcmp(vca_current, vca_previous)){ + s[s_count]=c->unicode; + s_count++; + free(vca_current); + continue; + } + if(s_count!=0){ + a=Tcl_NewListObj(0,NULL); + Tcl_ListObjAppendElement(interp,a,Tcl_NewIntObj(prev_x)); + Tcl_ListObjAppendElement(interp,a,Tcl_NewIntObj(prev_y)); + Tcl_ListObjAppendElement(interp,a,Tcl_NewStringObj(vca_previous,-1)); + Tcl_ListObjAppendElement(interp,a,Tcl_NewUnicodeObj(s,s_count)); + + Tcl_ListObjAppendElement(interp, lines, a); + } + free(vca_previous); + vca_previous=vca_current; + s[0]=c->unicode; + if(c->opacity!=VBI_TRANSPARENT_SPACE) + s_count=1; + else + s_count=0; + prev_x=l; + prev_y=k; + } + if(s_count!=0){ + a=Tcl_NewListObj(0,NULL); + Tcl_ListObjAppendElement(interp,a,Tcl_NewIntObj(prev_x)); + Tcl_ListObjAppendElement(interp,a,Tcl_NewIntObj(prev_y)); + Tcl_ListObjAppendElement(interp,a,Tcl_NewStringObj(vca_previous,-1)); + Tcl_ListObjAppendElement(interp,a,Tcl_NewUnicodeObj(s,s_count)); + Tcl_ListObjAppendElement(interp, lines, a); + } + s_count=0; + free(vca_previous); + vca_previous=strdup(""); + } +Tcl_SetObjResult(interp, lines); +return TCL_OK; +} + int vbi_close_device(ClientData client_data,Tcl_Interp* interp,int argc,const char *argv[]) { long i; @@ -526,6 +749,7 @@ {"vbi_set_event_handler", vbi_set_event_handler}, {"vbi_draw_cc_page", vbi_draw_cc_page2}, {"vbi_draw_cc_page_scaled", vbi_draw_cc_page_scaled}, + {"vbi_get_cc_page", vbi_get_cc_page}, {"vbi_close_device", vbi_close_device}, {NULL, NULL} }; Index: vbi.scp =================================================================== RCS file: /cvsroot/gatos/avview/vbi.scp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vbi.scp 16 Feb 2003 07:38:12 -0000 1.1 +++ vbi.scp 22 Feb 2003 06:56:56 -0000 1.2 @@ -3,7 +3,7 @@ proc skip_args3 { a b c } {} -proc vbi_event_handler { a b } { +proc vbi_event_handler_scaled { a b } { puts "$a $b" switch -exact -- $a { "caption" { @@ -44,7 +44,73 @@ trace variable $var w "puts \"+\" ; global vbi_caption_images $var; set vbi_caption_images($W.c) \[set $var\] ; skip_args3" } -vbi_open_device primary /dev/vbi0 -vbi_set_event_handler primary vbi_event_handler +proc render_vbi_line { canvas tag width height columns rows line } { +puts "line=$line" +foreach var {x y attr str} value $line { + set $var $value + } +set fontsize [expr $height/$rows] +foreach var {style effect size opacity foreground background} value [split $attr -] { + set $var $value + } +puts "fontsize=$fontsize" +switch -exact -- $style { + "" { + set font [font create -family Helvetica -size -$fontsize -slant roman -underline false -weight normal] + } + "u" { + set font [font create -family Helvetica -size -$fontsize -slant roman -underline true -weight normal] + } + "b" { + set font [font create -family Helvetica -size -$fontsize -slant roman -underline false -weight bold] + } + "ub" { + set font [font create -family Helvetica -size -$fontsize -slant roman -underline true -weight bold] + } + "i" { + set font [font create -family Helvetica -size -$fontsize -slant italic -underline false -weight normal] + } + "ui" { + set font [font create -family Helvetica -size -$fontsize -slant italic -underline true -weight normal] + } + "bi" { + set font [font create -family Helvetica -size -$fontsize -slant italic -underline false -weight bold] + } + "ubi" { + set font [font create -family Helvetica -size -$fontsize -slant italic -underline true -weight bold] + } + } +set a [$canvas create text [expr ($x*$width)/$columns] [expr ($y*$height)/$rows] -font $font -text $str -anchor nw \ + -fill $foreground ] +$canvas addtag $tag withtag $a +set bbox [$canvas bbox $a] +set b [$canvas create rectangle $bbox -fill $background] +$canvas raise $a +$canvas addtag $tag withtag $b +} + +proc vbi_event_handler_on_screen {a b} { +puts "vbi event $a $b" +catch { +switch -exact -- $a { + "caption" { + set cc_page [vbi_get_cc_page primary 1] + set width [lindex $cc_page 0] + set height [lindex $cc_page 1] + puts "$width x $height" + .video delete cc_text + puts "info=[place info .video]" + foreach line [lrange $cc_page 2 end] { + render_vbi_line .video cc_text [.video cget -width] [.video cget -height] $width $height $line + } + puts "ZXY" + update + } + } + } err +puts "err=$err" +} + +#vbi_open_device primary /dev/vbi0 +#vbi_set_event_handler primary vbi_event_handler_on_screen -new_vbi_window |