<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Things to check when writing an element</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79;charset=UTF-8"><LINK REL="HOME" TITLE="GStreamer Plugin Writer's Guide (0.10.36)" HREF="index.html"><LINK REL="UP" TITLE="Appendices" HREF="part-appendix.html"><LINK REL="PREVIOUS" TITLE="Appendices" HREF="part-appendix.html"><LINK REL="NEXT" TITLE="Debugging" HREF="section-checklist-debug.html"></HEAD ><BODY CLASS="chapter" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="application" >GStreamer</SPAN > Plugin Writer's Guide (0.10.36)</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="part-appendix.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="section-checklist-debug.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="chapter-checklist-element" ></A >Chapter 23. Things to check when writing an element</H1 ><P > This chapter contains a fairly random selection of things to take care of when writing an element. It's up to you how far you're going to stick to those guidelines. However, keep in mind that when you're writing an element and hope for it to be included in the mainstream <SPAN CLASS="application" >GStreamer</SPAN > distribution, it <SPAN CLASS="emphasis" ><I CLASS="emphasis" >has to</I ></SPAN > meet those requirements. As far as possible, we will try to explain why those requirements are set. </P ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="section-checklist-states" >23.1. About states</A ></H1 ><P ></P ><UL ><LI ><P > Make sure the state of an element gets reset when going to <CODE CLASS="classname" >NULL</CODE >. Ideally, this should set all object properties to their original state. This function should also be called from _init. </P ></LI ><LI ><P > Make sure an element forgets <SPAN CLASS="emphasis" ><I CLASS="emphasis" >everything</I ></SPAN > about its contained stream when going from <CODE CLASS="classname" >PAUSED</CODE > to <CODE CLASS="classname" >READY</CODE >. In <CODE CLASS="classname" >READY</CODE >, all stream states are reset. An element that goes from <CODE CLASS="classname" >PAUSED</CODE > to <CODE CLASS="classname" >READY</CODE > and back to <CODE CLASS="classname" >PAUSED</CODE > should start reading the stream from he start again. </P ></LI ><LI ><P > People that use <B CLASS="command" >gst-launch</B > for testing have the tendency to not care about cleaning up. This is <SPAN CLASS="emphasis" ><I CLASS="emphasis" >wrong</I ></SPAN >. An element should be tested using various applications, where testing not only means to <SPAN CLASS="QUOTE" >"make sure it doesn't crash"</SPAN >, but also to test for memory leaks using tools such as <B CLASS="command" >valgrind</B >. Elements have to be reusable in a pipeline after having been reset. </P ></LI ></UL ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="part-appendix.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="section-checklist-debug.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Appendices</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="part-appendix.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Debugging</TD ></TR ></TABLE ></DIV ></BODY ></HTML >