Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1284 closed enhancement (fixed)

Media event framework

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-2.0-alpha
Component: pjmedia Version: 2.0-dev-branch
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by bennylp)

Framework to publish and consume media events in a media flow. The event framework can be used by any media types (audio and video) and any objects.

Overview of the framework (pjmedia/event.h):

typedef enum pjmedia_event_type
{
    PJMEDIA_EVENT_NONE,
    PJMEDIA_EVENT_FMT_CHANGED,
    PJMEDIA_EVENT_WND_CLOSING,
    PJMEDIA_EVENT_WND_CLOSED,
    PJMEDIA_EVENT_WND_RESIZED,
    PJMEDIA_EVENT_MOUSE_BTN_DOWN,
    PJMEDIA_EVENT_KEY_FRAME_FOUND,
    PJMEDIA_EVENT_KEY_FRAME_MISSING,
    PJMEDIA_EVENT_USER = 100
} pjmedia_event_type;

typedef struct pjmedia_event
{
    pjmedia_event_type			 type;
    pj_timestamp		 	 timestamp;
    unsigned				 proc_cnt;
    const pjmedia_event_publisher	*epub;

    union {
	pjmedia_event_fmt_changed_data		fmt_changed;
	pjmedia_event_wnd_resized_data		wnd_resized;
	pjmedia_event_wnd_closing_data		wnd_closing;
	pjmedia_event_wnd_closed_data		wnd_closed;
	pjmedia_event_mouse_btn_down_data	mouse_btn_down;
	pjmedia_event_key_frame_found_data	key_frm_found;
	pjmedia_event_key_frame_missing_data	key_frm_missing;
	pjmedia_event_user_data			user;
	void					*ptr;
    } data;
} pjmedia_event;

typedef pj_status_t pjmedia_event_cb(pjmedia_event_subscription *esub,
				     pjmedia_event *event);

struct pjmedia_event_subscription
{
    PJ_DECL_LIST_MEMBER(pjmedia_event_subscription);
    pjmedia_event_cb	*cb;
    void		*user_data;
};

struct pjmedia_event_publisher
{
    pjmedia_event_subscription	subscription_list;
};

PJ_DECL(void) pjmedia_event_init(pjmedia_event *event,
                                 pjmedia_event_type type,
                                 const pj_timestamp *ts,
                                 const pjmedia_event_publisher *epub);
PJ_DECL(void) pjmedia_event_publisher_init(pjmedia_event_publisher *epub);
PJ_DECL(void) pjmedia_event_subscription_init(pjmedia_event_subscription *esub,
                                              pjmedia_event_cb *cb,
                                              void *user_data);
PJ_DECL(pj_status_t) pjmedia_event_subscribe(pjmedia_event_publisher *epub,
                                             pjmedia_event_subscription *esub);
PJ_DECL(pj_status_t) pjmedia_event_unsubscribe(pjmedia_event_publisher *epub,
                                               pjmedia_event_subscription *esub);
PJ_DECL(pj_status_t) pjmedia_event_publish(pjmedia_event_publisher *epub,
                                           pjmedia_event *event);
PJ_DECL(pj_status_t) pjmedia_event_republish(pjmedia_event_publisher *esrc,
                                             pjmedia_event_publisher *epub,
                                             pjmedia_event_subscription *esub);

Change History (13)

comment:1 Changed 8 years ago by nanang

  • Description modified (diff)

comment:2 Changed 8 years ago by bennylp

  • Owner changed from nanang to bennylp
  • Status changed from new to assigned

comment:3 Changed 8 years ago by bennylp

  • Description modified (diff)
  • Summary changed from Event mechanism (e.g. format change) to Media event framework

comment:4 Changed 8 years ago by bennylp

  • Description modified (diff)

comment:5 Changed 8 years ago by bennylp

(In [3617]) Initial implementation of re #1284 (Event Framework). Current event has been converted to the new framework. Next to convert is codec event

comment:6 Changed 8 years ago by bennylp

  • Description modified (diff)

comment:7 Changed 8 years ago by bennylp

  • Description modified (diff)

comment:8 Changed 8 years ago by ming

(In [3621]) Re #1284
Fixed compilation error on Mac (minor)

comment:9 Changed 8 years ago by bennylp

(In [3622]) More on re #1284:

  • Replaced bit_info mechanism to report format change in codec with event
  • Updated vid_port, vid_codec_test, etc.
  • Add event publisher to vid_codec
  • Add event publisher to pjmedia_port
  • Add event publisher to vid_stream

comment:10 Changed 8 years ago by bennylp

(In [3628]) More re #1284: generate PJMEDIA_EVENT_KEY_FRAME_FOUND from ffmpeg_codecs.c

comment:11 Changed 8 years ago by bennylp

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:12 Changed 8 years ago by bennylp

(In [3642]) More re #1284 (event): changed event to use the fourcc value for better extensibility and readability

comment:13 Changed 8 years ago by bennylp

(In [3653]) Re #1284 (event framework): unsubscribing does not need to know publisher

Note: See TracTickets for help on using tickets.