filter_chain: introduce dedicated filter_chain_NewVideo() for video filters
[vlc.git] / modules / video_filter / canvas.c
index 0abbd58..b81a187 100644 (file)
@@ -41,7 +41,6 @@
 static int  Activate( vlc_object_t * );
 static void Destroy( vlc_object_t * );
 static picture_t *Filter( filter_t *, picture_t * );
-static int alloc_init( filter_t *, void * );
 
 /* This module effectively implements a form of picture-in-picture.
  *  - The outer picture is called the canvas.
@@ -132,6 +131,16 @@ struct filter_sys_t
     filter_chain_t *p_chain;
 };
 
+static picture_t *video_new( filter_t *p_filter )
+{
+    return filter_NewPicture( p_filter->owner.sys );
+}
+
+static void video_del( filter_t *p_filter, picture_t *p_pic )
+{
+    return filter_DeletePicture( p_filter->owner.sys, p_pic );
+}
+
 /*****************************************************************************
  *
  *****************************************************************************/
@@ -226,8 +235,15 @@ static int Activate( vlc_object_t *p_this )
         return VLC_ENOMEM;
     p_filter->p_sys = p_sys;
 
-    p_sys->p_chain = filter_chain_New( p_filter, "video filter2", true,
-                                       alloc_init, NULL, p_filter );
+    filter_owner_t owner = {
+        .sys = p_filter,
+        .video = {
+            .buffer_new = video_new,
+            .buffer_del = video_del,
+        },
+    };
+
+    p_sys->p_chain = filter_chain_NewVideo( p_filter, true, &owner );
     if( !p_sys->p_chain )
     {
         msg_Err( p_filter, "Could not allocate filter chain" );
@@ -364,24 +380,3 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 {
     return filter_chain_VideoFilter( p_filter->p_sys->p_chain, p_pic );
 }
-
-/*****************************************************************************
- *
- *****************************************************************************/
-static picture_t *video_new( filter_t *p_filter )
-{
-    return filter_NewPicture( p_filter->owner.sys );
-}
-
-static void video_del( filter_t *p_filter, picture_t *p_pic )
-{
-    return filter_DeletePicture( p_filter->owner.sys, p_pic );
-}
-
-static int alloc_init( filter_t *p_filter, void *p_data )
-{
-    p_filter->owner.sys = p_data;
-    p_filter->owner.video.buffer_new = video_new;
-    p_filter->owner.video.buffer_del = video_del;
-    return VLC_SUCCESS;
-}