#!/usr/bin/env python3

import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GstVideo


class Bug(GstVideo.VideoFilter):
    __CAPS = "video/x-raw, format=I420, width=[1, 2147483647], height=[1, 2147483647], framerate=[0/1, 2147483647/1]"

    __gstdetails__ = (
        'bug',
        'sample code',
        '',
        'ticapix@gmail.com',
    ) # __gstdetails__

    __gsttemplates__ = (
        Gst.PadTemplate.new("sink",
            Gst.PadDirection.SINK,
            Gst.PadPresence.ALWAYS,
            Gst.caps_from_string(__CAPS)),
 
        Gst.PadTemplate.new("src",
            Gst.PadDirection.SRC,
            Gst.PadPresence.ALWAYS,
            Gst.caps_from_string(__CAPS)),
    ) # __gsttemplates__

    def __init__(self):
        super(Bug, self).__init__()

    def do_transform_frame(self, inframe, outframe):
        if self.is_passthrough():
            return Gst.FlowReturn.OK
        assert inframe.info.width == outframe.info.width
        assert inframe.info.height == outframe.info.height

        ret = outframe.buffer.fill(0, [0])
        assert ret == 1
