Skip to content

Commit

Permalink
fixed play event in python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Jan 22, 2024
1 parent 63ee0c1 commit 5bc6455
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 8 deletions.
17 changes: 16 additions & 1 deletion share/nodejs/src/gpac_napi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* GPAC - Multimedia Framework C SDK
*
* Authors: Jean Le Feuvre
* Copyright (c) Telecom ParisTech 2021-2023
* Copyright (c) Telecom ParisTech 2021-2024
* All rights reserved
*
* This file is part of GPAC / NodeJS module
Expand Down Expand Up @@ -4136,6 +4136,11 @@ static u32 FEVT_PROP_NTP_REF = 62;
static u32 FEVT_PROP_NAME = 63;
static u32 FEVT_PROP_UI_NAME = 64;
static u32 FEVT_PROP_PID = 65;
static u32 FEVT_PROP_TO_PCK = 66;
static u32 FEVT_PROP_ORIG_DELAY = 67;
static u32 FEVT_PROP_HINT_FIRST_DTS = 68;
static u32 FEVT_PROP_HINT_START_OFFSET = 69;
static u32 FEVT_PROP_HINT_END_OFFSET = 70;


#define FILTEREVENT\
Expand All @@ -4161,6 +4166,11 @@ static u32 FEVT_PROP_PID = 65;
EVT_BOOL(FEVT_PROP_FORCED_DASH_SWITCH, evt->play.forced_dash_segment_switch);\
EVT_BOOL(FEVT_PROP_DROP_NON_REF, evt->play.drop_non_ref);\
EVT_BOOL(FEVT_PROP_NO_BYTERANGE, evt->play.no_byterange_forward);\
EVT_U32(FEVT_PROP_TO_PCK, evt->play.to_pck);\
EVT_U32(FEVT_PROP_ORIG_DELAY, evt->play.orig_delay);\
EVT_U64(FEVT_PROP_HINT_FIRST_DTS, evt->play.hint_first_dts);\
EVT_U64(FEVT_PROP_HINT_START_OFFSET, evt->play.hint_start_offset);\
EVT_U64(FEVT_PROP_HINT_END_OFFSET, evt->play.hint_end_offset);\
EVT_U64(FEVT_PROP_START_OFFSET, evt->seek.start_offset);\
EVT_U64(FEVT_PROP_END_OFFSET, evt->seek.end_offset);\
EVT_U32(FEVT_PROP_HINT_BLOCK_SIZE, evt->seek.hint_block_size);\
Expand Down Expand Up @@ -4421,6 +4431,11 @@ napi_value wrap_filterevent(napi_env env, GF_FilterEvent *evt, napi_value *for_v
{ "forced_dash_segment_switch", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_FORCED_DASH_SWITCH},
{ "drop_non_ref", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_DROP_NON_REF},
{ "no_byterange_forward", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_NO_BYTERANGE},
{ "to_pck", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_TO_PCK},
{ "orig_delay", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_ORIG_DELAY},
{ "hint_first_dts", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_HINT_FIRST_DTS},
{ "hint_start_offset", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_HINT_START_OFFSET},
{ "hint_end_offset", NULL, NULL, fevt_getter, evt_set, NULL, napi_enumerable, &FEVT_PROP_HINT_END_OFFSET},
};
NAPI_CALL( napi_define_properties(env, obj, sizeof(fevt_properties)/sizeof(napi_property_descriptor), fevt_properties) );
}
Expand Down
169 changes: 163 additions & 6 deletions share/python/libgpac/libgpac.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# GPAC - Multimedia Framework C SDK
#
# Authors: Jean Le Feuvre
# Copyright (c) Telecom Paris 2020-2023
# Copyright (c) Telecom Paris 2020-2024
# All rights reserved
#
# Python ctypes bindings for GPAC (core initialization and filters API only)
Expand Down Expand Up @@ -734,7 +734,12 @@ class FEVT_Play(Structure):
("full_file_only", c_ubyte),
("forced_dash_segment_switch", c_ubyte),
("drop_non_ref", c_ubyte),
("no_byterange_forward", c_ubyte)
("no_byterange_forward", c_ubyte),
("to_pck", c_uint),
("orig_delay", c_uint),
("hint_first_dts", c_ulonglong),
("hint_start_offset", c_ulonglong),
("hint_end_offset", c_ulonglong)
]
## \endcond

Expand Down Expand Up @@ -766,7 +771,24 @@ class FEVT_SegmentSize(Structure):
("media_range_start", c_ulonglong),
("media_range_end", c_ulonglong),
("idx_range_start", c_ulonglong),
("idx_range_end", c_ulonglong)
("idx_range_end", c_ulonglong),
("is_init", c_ubyte),
("is_shift", c_ubyte)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_FragmentSize
class FEVT_FragmentSize(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("is_last", gf_bool),
("offset", c_ulonglong),
("size", c_ulonglong),
("duration", Fraction64),
("independent", gf_bool),
]
## \endcond

Expand Down Expand Up @@ -840,6 +862,138 @@ class FEVT_BufferRequirement(Structure):
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_EncodeHints
class FEVT_EncodeHints(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("intra_period", Fraction),
("gen_dsi_only", gf_bool)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_NTPRef
class FEVT_NTPRef(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("ntp", c_ulonglong)
]
## \endcond


## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventMouse
class EVT_mouse(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("x", c_int),
("y", c_int),
("wheel", c_float),
("button", c_int),
("keys", c_uint),
("window_id", c_uint)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventMultiTouch
class EVT_mtouch(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("x", c_float),
("y", c_float),
("rotation", c_float),
("pinch", c_float),
("num_fingers", c_uint),
("window_id", c_uint)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventKey
class EVT_keys(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("key_code", c_uint),
("hw_code", c_uint),
("flags", c_uint),
("window_id", c_uint)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventChar
class EVT_char(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("unicode_char", c_uint),
("window_id", c_uint)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventSize
class EVT_size(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("width", c_uint),
("height", c_uint),
("orientation", c_uint),
("window_id", c_uint)
]
## \endcond

## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventShow
class EVT_show(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("show_type", c_uint),
("window_id", c_uint)
]
## \endcond


## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as GF_Event
#only common events from GPAC video ouput are mapped
class EVT_base(Union):
## \cond private
_fields_ = [
("type", c_ubyte),
("mouse", EVT_mouse),
("mtouch", EVT_mtouch),
("keys", EVT_keys),
("char", EVT_char),
("size", EVT_size),
("show", EVT_show)
]
## \endcond


## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_Event
class FEVT_UserEvent(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("event", EVT_base)
]
## \endcond


## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as GF_FilterEvent
class FilterEvent(Union):
Expand All @@ -855,12 +1009,15 @@ def __init__(self, type=0):
("play", FEVT_Play),
("seek", FEVT_SourceSeek),
("attach_scene", FEVT_AttachScene),
#("user_event", FEVT_Event,
("user", FEVT_UserEvent),
("quality_switch", FEVT_QualitySwitch),
("visibility_hint", FEVT_VisibilityHint),
("buffer_req", FEVT_BufferRequirement),
("seg_size", FEVT_SegmentSize),
("file_del", FEVT_FileDelete)
("frag_size", FEVT_FragmentSize),
("file_del", FEVT_FileDelete),
("encode_hints", FEVT_EncodeHints),
("ntp", FEVT_NTPRef)
]
## \endcond

Expand Down Expand Up @@ -3824,7 +3981,7 @@ def has_seen_eos(self):
##True if end of stream was seen on pid but some packets are still pending - see \ref gf_filter_pid_eos_received
#\return
@property
def eos_receievd(self):
def eos_received(self):
return _libgpac.gf_filter_pid_eos_received(self._pid)

##True if PID would block - see \ref gf_filter_pid_would_block
Expand Down

0 comments on commit 5bc6455

Please sign in to comment.