sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.57k stars 268 forks source link

Does go-sciter have a use case for video rendering? #332

Open xs23933 opened 2 years ago

xs23933 commented 2 years ago

I need to do video rendering about video frame

Render the h264 frame decoded by libavcodec to the display

Only see sciter VIDEO_BIND_RQ but no use case

或者任何 in-memory:cursor demo

pravic commented 2 years ago

I doubt we support VIDEO_BIND_RQ in Go.

Here's an example in C++: https://github.com/c-smile/sciter-sdk/blob/master/include/behaviors/behavior_video_generator.cpp#L40-L60

xs23933 commented 2 years ago

thanks I will study again

xs23933 commented 2 years ago

sciter-x-video-api.h is c++ syntax so it is difficult

I modified the file name sciter-x-video-api.hpp and include it But the compiler still prompts error: unknown type name 'namespace'

xs23933 commented 2 years ago

add scider-x-video.h use c style but how to call library member method , i can't


#ifndef __SCITER_X_VIDEO__
#define __SCITER_X_VIDEO__

#include <sciter-x.h>

typedef struct video_source {
    SBOOL SCFN( play )();
    SBOOL SCFN( pause )();
    SBOOL SCFN( stop )();
    SBOOL SCFN( get_is_ended )(SBOOL *eos);
    SBOOL SCFN( get_position )(double *seconds);
    SBOOL SCFN( set_position )(double seconds);
    SBOOL SCFN( get_duration )(double *seconds);
    // audio
    SBOOL SCFN( get_volume )(double* vol);
    SBOOL SCFN( set_volume )(double vol);
    SBOOL SCFN( get_balance )(double* vol);
    SBOOL SCFN( set_balance )(double vol);
} video_source_t;

typedef struct video_destination{
    SBOOL SCFN( is_alive )();
    SBOOL SCFN( start_streaming )(
        INT frame_width,
        INT frame_height,
        INT color_space,
        video_source_t* src
    );
    SBOOL SCFN( stop_streaming )();
    SBOOL SCFN( render_frame )(const BYTE* frame_data, UINT frame_data_size);
} video_destination_t;

video_destination_t* SVAPI() {
    return _SVAPI(NULL);
};

#endif

video.go

package sciter

// #include "sciter-x.h"
import "C"
import "unsafe"

type VideoSource C.video_source_t

type VideoDestination C.video_destination_t

func NewVideoDestination(ptr C.UINT_PTR) *VideoDestination {
    vd := &VideoDestination{}
    vd = (*VideoDestination)(unsafe.Pointer(uintptr(ptr)))
    return vd
}