[meego-commits] 24443: Changes to MeeGo:1.2:oss/UMMS

rui_long no_reply at build.meego.com
Mon Oct 31 03:04:37 UTC 2011


Hi,
I have made the following changes to UMMS in project MeeGo:1.2:oss. Please review and accept ASAP.

Thank You,
rui_long

[This message was auto-generated]

---

Request #24443:

  submit:   devel:tv:1.2/UMMS(r7)(update) -> MeeGo:1.2:oss/UMMS


Message:
    TV only package update

State:   new          2011-10-30T19:50:39 rui_long
Comment: None



changes files:
--------------
--- umms.changes
+++ umms.changes
@@ -0,0 +1,16 @@
+Sun Oct 30 2011 Zhiwen Wu <zhiwen.wu at intel.com>- 0.0.1
+- Fix a memory leak when tag_list updated in bus_message_get_tag_cb().
+- Fix a occasional crash when "video-tags-changed" and "audio-tags-changed" are reported simultanously.
+
+Fri Oct 28 2011 Hejun Yan <junyan.he at intel.com>- 0.0.1
+- Fix Bug "Unable to set scale mode,it is always the default "0" mode"
+
+Fri Oct 28 2011 Zhiwen Wu <zhiwen.wu at intel.com>- 0.0.1
+- Fix Bug "video can't play smoothly after seek through javascript API"
+
+Thu Oct 27 2011 Zhiwen Wu <zhiwen.wu at intel.com>- 0.0.1
+- Fix Bug "HTML5-Fail to replay video Sometimes"
+- Fix Bug "freeze the playback while scroll the browser (calling javascript API)"
+- Remove "example" directory.
+- Add COPYING file.
+

spec files:
-----------

other changes:
--------------

++++++ umms-0.0.1.tar.gz
--- COPYING
+++ COPYING
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
--- Makefile.am
+++ Makefile.am
@@ -1 +1 @@
-SUBDIRS=src spec libummsclient examples test test/ui
+SUBDIRS=src spec libummsclient test test/ui
--- configure.in
+++ configure.in
@@ -45,7 +45,6 @@
 # Checks for library functions.
 
 AC_CONFIG_FILES([Makefile
-				 examples/Makefile
 				 test/Makefile
 				 libummsclient/Makefile
 				 spec/Makefile
--- examples
+++ examples
-(directory)
--- examples/Makefile.am
+++ examples/Makefile.am
-noinst_PROGRAMS = sample-client-gobject
-sample_client_gobject_CFLAGS = $(UMMSCLIENT_CFLAGS)
-sample_client_gobject_LDFLAGS = $(UMMSCLIENT_LIBS)
-sample_client_gobject_LDADD = ../libummsclient/libummsclient.a
-sample_client_gobject_SOURCES = sample-client-gobject.c \
-							  ../src/umms-marshals.c \
-							  ../src/umms-marshals.h
-
-
-EXTRA_DIST = sample-client.py
--- examples/client.py
+++ examples/client.py
-#!/usr/bin/env python
-
-import gobject
-import dbus
-import dbus.mainloop.glib
-import dbus.glib
-import threading
-import string
-
-
-
-def initialized_cb():
-	print "MeidaPlayer initialized"
-
-def player_state_changed_cb(state):
-	print "State changed to '%s'" % state_name[state]
-
-def eof_cb ():
-	print "EOF...."
-
-def begin_buffering_cb():
-    print "Begin buffering"
-
-def buffered_cb():
-    print "Buffering completed"
-
-def seeked_cb():
-    print "Seeking completed"
-
-def stopped_cb():
-    print "Player stopped"
-
-def error_cb(err_id, msg):
-    print "Error Domain:'%s', msg='%s'" % (error_type_name[err_id], msg)
-
-def request_window_cb():
-    print "Player engine request a X window"
-
-
-   
-
-class CmdHandler(threading.Thread):
-    def __init__(self, obj_mngr):
-        threading.Thread.__init__(self)
-        self.mngr = obj_mngr
-	
-    def run(self):
-        quit = False
-        while quit == False:
-            cmd = raw_input ("Input cmd:\n")
-            quit = (self.handle_cmd(cmd) == False)
-        else :
-            loop.quit()
-	
-    def handle_cmd(self, cmd):
-        ret = True
-        if cmd.isalpha():
-            if cmd == "q":
-                ret = False
-            else:
-                self.print_help()
-
-        elif cmd.isdigit():
-            method_id = int(cmd)
-            ret = self.remote_call(method_id)
-        else:
-            ret = False;
-        return ret
-
-    def print_help(self):
-        print '  ===========Usage============'
-        print "  q:\tto quit this program"
-        print "  h:\tprint this usage"
-        for i in range(0, len(method_name)):
-            print "  %d:\t%s" % (i, method_name[i])
-
-    def get_player(self, name):
-        print "Create proxy for remote player '%s'" % (name)
-        bus=dbus.SessionBus()
-        bus_obj=bus.get_object("com.UMMS", name)
-        proxy=dbus.Interface(bus_obj, 'com.UMMS.MediaPlayer')
-        proxy.connect_to_signal("Initialized", initialized_cb)
-        proxy.connect_to_signal("Eof", eof_cb)
-        proxy.connect_to_signal("Buffering", begin_buffering_cb)
-        proxy.connect_to_signal("Buffered", buffered_cb)
-        proxy.connect_to_signal("RequestWindow", request_window_cb)
-        proxy.connect_to_signal("Seeked", seeked_cb)
-        proxy.connect_to_signal("Stopped", stopped_cb)
-        proxy.connect_to_signal("Error", error_cb)
-        proxy.connect_to_signal("PlayerStateChanged", player_state_changed_cb)
-        return proxy
-		
-    def remote_call(self, mid):
-        print "Begin remote_call, method_id = '%d'" % (mid)
-        global player_name
-        if mid == 0:
-            print "RequestMediaPlayer"
-            player_name = self.mngr.RequestMediaPlayer()
-            player.append(self.get_player (player_name)) 
-        elif mid == 1:
-            time_to_execute = float(raw_input("Input the MediaPlayer execution duration (in second):\n")) 
-            print "RequestMediaPlayerUnattended(%f s)" % time_to_execute
-            (token, player_name) = self.mngr.RequestMediaPlayerUnattended(time_to_execute)
-            print "token = '%s', player_name = '%s'" % (token, player_name)
-            player.append(self.get_player (player_name)) 
-        elif mid == 2:
-            print "Remove '%s'" % (player_name)
-            self.mngr.RemoveMediaPlayer(player_name)
-        elif mid == 3:
-            uri = raw_input("Input the uri to playback, default: '%s'\n" % (default_uri))
-            print "uri to playback :'%s'" % (uri)
-            if uri == "":
-                player[0].SetUri(default_uri)
-            else :
-                player[0].SetUri(uri)
-        elif mid == 4:
-            print "Play"
-            player[0].Play()
-        elif mid == 5:
-            print "Pause"
-            player[0].Pause()
-        elif mid == 6:
-            print "Stop"
-            player[0].Stop()
-        elif mid == 7:
-            pos = 1000*int(raw_input ("Input pos to seek: (seconds)\n"))
-            print "SetPosition to '%d' ms" % pos
-            player[0].SetPosition(pos)
-        elif mid == 8:
-            pos = player[0].GetPosition()
-            print "Current Position : '%d' ms" % (pos)
-        elif mid == 9:
-        	rate = float(raw_input("Input playback rate: "))
-        	print "Set rate to '%f'" % rate
-        	player[0].SetPlaybackRate(rate)
-        elif mid == 10:
-        	rate = player[0].GetPlaybackRate()
-        	print "Current rate is '%f'" % rate
-        elif mid == 11:
-            vol = int(raw_input ("Input volume to set: [0,100]\n"))
-            print "SetVolume to %d" % vol
-            player[0].SetVolume(vol)
-        elif mid == 12:
-        	vol = player[0].GetVolume()
-        	print "Current vol is '%d'" % vol
-        elif mid == 13:
-        	print "TODO:"
-        elif mid == 14:
-            rectangle = raw_input ("Input dest reactangle, Example: 0,0,352,288\n")
-            rectangle = rectangle.split(',')
-            x = int(rectangle[0])
-            y = int(rectangle[1])
-            w = int(rectangle[2])
-            h = int(rectangle[3])
-            print "SetVideoSize (%d,%d,%d,%d)" % (x,y,w,h) 
-            player[0].SetVideoSize(x,y,w,h)
-        elif mid == 15:
-        	(width, height) = player[0].GetVideoSize()
-        	print "width=%d, height=%d" % (width, height)
-        elif mid == 16:
-        	buffered_time = player[0].GetBufferedTime()
-        	print "Buffered time = %d" % buffered_time
-        elif mid == 17:
-        	buffered_bytes = player[0].GetBufferedBytes()
-        	print "Buffered bytes = %d" % buffered_bytes
-        elif mid == 18:
-        	duration = player[0].GetMediaSizeTime()
-        	print "Duration is '%d'" % duration
-        elif mid == 19:
-        	size = player[0].GetMediaSizeBytes()
-        	print "Media file size = %d" % size
-        elif mid == 20:
-        	ret = player[0].HasVideo()
-        	print "Has video is %d" % ret
-        elif mid == 21:
-        	ret = player[0].HasAudio()
-        	print "Has audio is %d" % ret
-        elif mid == 22:
-        	ret = player[0].IsStreaming()
-        	print "IsStreaming = %d" % ret
-        elif mid == 23:
-        	ret = player[0].IsSeekable()
-        	print "IsSeekable = %d" % ret
-        elif mid == 24:
-        	ret = player[0].SupportFullscreen()
-        	print "SupportFullscreen = %d" % ret
-        elif mid == 25:
-        	state = player[0].GetPlayerState()
-        	print "Current state = '%s'" % state_name[state]
-        else:
-        	print "Unsupported method id '%d'" % (mid)
-        	self.print_help(self);
-        return True
-
-error_type_name = (
-    	"ErrorTypeEngine",
-    	"NumOfErrorType"
-	)
-
-state_name = (
-	"PlayerStateNull",
-	"PlayerStatePaused",
-	"PlayerStatePlaying",
-	"PlayerStateStopped"
-)
-
-method_name = (
-	"RequestMediaPlayer",
-	"RequestMediaPlayerUnattended",
-	"RemoveMediaPlayer",
-	
-	"SetUri",#3
-	"Play",
-	"Pause",
-	"Stop",
-	
-	"SetPosition",#7
-	"GetPosition",
-	"SetPlaybackRate",
-	"GetPlaybackRate",
-	"SetVolume",
-	"GetVolume",
-	"SetWindowId",
-	"SetVideoSize",
-	"GetVideoSize",
-	"GetBufferedTime",
-	"GetBufferedBytes",
-	"GetMediaSizeTime",
-	"GetMediaSizeBytes",
-	"HasVideo",#20
-	"HasAudio",
-	"IsStreaming",
-	"IsSeekable",
-	"SupportFullscreen",
-	"GetPlayerState"
-	)
-
-default_uri = "file:///root/720p.m4v"
-player = []
-player_name = ""
-
-if __name__ == '__main__':
-
-
-    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
-
-    bus=dbus.SessionBus()
-    bus_obj=bus.get_object('com.UMMS', '/com/UMMS/ObjectManager')
-    iface=dbus.Interface(bus_obj, 'com.UMMS.ObjectManager.iface')
-	
-    gobject.threads_init()
-    dbus.glib.init_threads()
-
-    cmd_handler = CmdHandler(iface)
-    cmd_handler.start()
-	
-    loop = gobject.MainLoop()
-    loop.run()
-    print "Client exit...."
-
--- examples/sample-client-gobject.c
+++ examples/sample-client-gobject.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib-object.h>
-
-#include "../src/umms-marshals.h"
-#include "../src/umms-debug.h"
-#include "../libummsclient/umms-client-object.h"
-
-const gchar *error_type[] = {
-  "ErrorTypeEngine",
-  "NumOfErrorType"
-};
-
-const gchar *state_name[] = {
-  "PlayerStateNull",
-  "PlayerStatePaused",
-  "PlayerStatePlaying",
-  "PlayerStateStopped"
-};
-
-#define N_UMMS_METHOD 23
-
-GMainLoop *loop;
-static UmmsClientObject *umms_client_obj = NULL;
-static DBusGProxy *player = NULL;
-
-#define DEFAULT_URI "file:///root/720p.m4v"
-
-void initialized_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG ("MeidaPlayer initialized");
-}
-
-void player_state_changed_cb(DBusGProxy *player, gint state, gpointer user_data)
-{
-  UMMS_DEBUG("State changed to '%s'", state_name[state]);
-}
-
-void eof_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG( "EOF....");
-}
-
-void begin_buffering_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG( "Begin buffering");
-}
-
-void buffered_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG( "Buffering completed");
-}
-
-void seeked_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG( "Seeking completed");
-}
-
-void stopped_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG( "Player stopped");
-}
-
-void error_cb(DBusGProxy *player, guint err_id, gchar *msg, gpointer user_data)
-{
-  UMMS_DEBUG( "Error Domain:'%s', msg='%s'", error_type[err_id], msg);
-}
-
-void request_window_cb(DBusGProxy *player, gpointer user_data)
-{
-  UMMS_DEBUG( "Player engine request a X window");
-}
-
-static void
-add_sigs(DBusGProxy *player)
-{
-  dbus_g_proxy_add_signal (player, "Initialized", G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "Eof", G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "Buffering", G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "Buffered", G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "RequestWindow", G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "Seeked", G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "Stopped", G_TYPE_INVALID);
-
-  dbus_g_object_register_marshaller (umms_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "Error", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
-  dbus_g_proxy_add_signal (player, "PlayerStateChanged", G_TYPE_INT, G_TYPE_INVALID);
-}
-
-static void
-connect_sigs(DBusGProxy *player)
-{
-  UMMS_DEBUG ("called");
-  dbus_g_proxy_connect_signal (player,
-      "Initialized",
-      G_CALLBACK(initialized_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "Eof",
-      G_CALLBACK(eof_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "Buffering",
-      G_CALLBACK(begin_buffering_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "Buffered",
-      G_CALLBACK(buffered_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "RequestWindow",
-      G_CALLBACK(request_window_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "Seeked",
-      G_CALLBACK(seeked_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "Stopped",
-      G_CALLBACK(stopped_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "Error",
-      G_CALLBACK(error_cb),
-      NULL, NULL);
-
-  dbus_g_proxy_connect_signal (player,
-      "PlayerStateChanged",
-      G_CALLBACK(player_state_changed_cb),
-      NULL, NULL);
-}
-
-static gboolean quit_play (gpointer data)
-{
-  GError *error = NULL;
-  if (!dbus_g_proxy_call (player, "Stop", &error,
-       G_TYPE_INVALID,
-       G_TYPE_INVALID)) {
-    UMMS_GERROR ("Failed to Stop", error);
-  }
-
-  umms_client_object_remove_player (umms_client_obj, player);
-  g_main_loop_quit (loop);
-  return FALSE;
-}
-
-int main (int argc, char **argv)
-{
-  GError *error = NULL;
-  gchar *obj_path;
-
-  g_type_init ();
-
-  umms_client_obj = umms_client_object_new();
-  player = umms_client_object_request_player (umms_client_obj, TRUE, 0, &obj_path);
-  add_sigs (player);
-  connect_sigs (player);
-
-  if (!dbus_g_proxy_call (player, "SetUri", &error,
-       G_TYPE_STRING, DEFAULT_URI, G_TYPE_INVALID,
-       G_TYPE_INVALID)) {
-    UMMS_GERROR ("Failed to SetUri", error);
-  }
-
-  if (!dbus_g_proxy_call (player, "Play", &error,
-       G_TYPE_INVALID,
-       G_TYPE_INVALID)) {
-    UMMS_GERROR ("Failed to Play", error);
-  }
-
-  g_timeout_add (10000, quit_play, NULL);
-
-  loop = g_main_loop_new (NULL, TRUE);
-
-  g_main_loop_run (loop);
-  g_main_loop_unref (loop);
-
-  g_object_unref (G_OBJECT (player));
-
-  exit(0);
-}
--- examples/sample-client.py
+++ examples/sample-client.py
-#!/usr/bin/python
-
-import gobject
-import libummsclient
-
-if __name__ == '__main__':
-
-    libummsclient.init()
-    (player, name) = libummsclient.request_player(True, 0)
-
-    player.SetUri("file:///root/720p.m4v")
-    player.Play()
-
-    loop = gobject.MainLoop()
-    loop.run()
-    print "Client exit...."
-
--- src/Makefile.am
+++ src/Makefile.am
@@ -33,6 +33,8 @@
 					          	engine-gst.h \
 					            engine-generic.c \
 					          	engine-generic.h \
+					            engine-dvb-generic.c \
+					          	engine-dvb-generic.h \
 					            umms-object-manager.c \
 					          	umms-object-manager.h \
 					          	param-table.c \
--- src/audio-manager-engine.c
+++ src/audio-manager-engine.c
@@ -192,14 +192,14 @@
 {
   AudioManagerInterfaceClass *klass = (AudioManagerInterfaceClass *)iface;
 
-//  audio_manager_interface_implement_set_volume (klass,
-//      audio_manager_engine_set_volume);
-//  audio_manager_interface_implement_get_volume (klass,
-//      audio_manager_engine_get_volume);
-//  audio_manager_interface_implement_set_state (klass,
-//      audio_manager_engine_set_state);
-//  audio_manager_interface_implement_get_state (klass,
-//      audio_manager_engine_get_state);
+  audio_manager_interface_implement_set_volume (klass,
+      audio_manager_engine_set_volume);
+  audio_manager_interface_implement_get_volume (klass,
+      audio_manager_engine_get_volume);
+  audio_manager_interface_implement_set_state (klass,
+      audio_manager_engine_set_state);
+  audio_manager_interface_implement_get_state (klass,
+      audio_manager_engine_get_state);
 }
 
 static void
@@ -257,6 +257,45 @@
 
 }
 
+static gboolean
+set_sink_caps (GstElement *asink)
+{
+  GstPad *sink_pad = NULL;
+  GstCaps *caps = NULL;
+  gboolean ret = FALSE;
+
+  caps = gst_caps_new_simple ("audio/x-raw-int", NULL);
+  sink_pad = gst_element_get_pad (asink, "sink");
+
+  if (!sink_pad) {
+    UMMS_DEBUG ("Getting sink pad failed");
+    goto out;
+  }
+
+  if (!(ret = gst_pad_set_caps (sink_pad, caps))) {
+    UMMS_DEBUG ("set caps failed");
+    goto out;
+  }
+
+  ret = TRUE;
+
+out:
+  if (caps) {
+    gst_caps_unref (caps);
+  }
+
+  if (sink_pad){
+    g_object_unref (sink_pad);
+  }
+
+  if (ret) {
+    UMMS_DEBUG ("Succeed");
+  }
+
+  return ret; 
+}
+
+
 static void
 audio_manager_engine_init (AudioManagerEngine *self)
 {
@@ -282,11 +321,13 @@
   UMMS_DEBUG ("get audio sink state = %d, ret = %d", state, ret);
   switch (ret) {
     case GST_STATE_CHANGE_FAILURE:
-      UMMS_DEBUG ("ismd_audio_sink failed to go playing");
+      UMMS_DEBUG ("ismd_audio_sink failed to go ready");
       goto FAILED;
       break;
     case GST_STATE_CHANGE_SUCCESS:
-      UMMS_DEBUG ("Setting ismd_audio_sink to playing succeed");
+      UMMS_DEBUG ("Setting ismd_audio_sink to ready succeed");
+      //to make the ismd_audio_sink configure the output.
+      set_sink_caps(priv->asink);
       return;
       break;
     default:
--- src/com.meego.UMMS.conf
+++ src/com.meego.UMMS.conf
-<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
-
-<!DOCTYPE busconfig PUBLIC
- "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-  <policy context="default">
-    <allow own="com.meego.UMMS"/>
-    <allow send_destination="com.meego.UMMS"/>
-  </policy>
-</busconfig>
--- src/com.meego.UMMS.service.in
+++ src/com.meego.UMMS.service.in
-[D-BUS Service]
-Name=com.meego.UMMS
-Exec=@dir@/umms-server
-User=root
--- src/dvb-player.c
+++ src/dvb-player.c
@@ -1396,8 +1396,11 @@
     UMMS_DEBUG ("Creating filesink failed");
     goto out;
   }
+  /*Same reason with appsink*/
+  g_object_set (G_OBJECT (filesink), "async", FALSE, NULL);
   gst_object_ref_sink (filesink);
 
+
 #define DEFAULT_FILE_LOCATION "/tmp/record.ts"
   if (location && location[0] != '\0')
     file_location = location;
@@ -1725,6 +1728,11 @@
   gst_app_sink_set_callbacks (GST_APP_SINK_CAST (appsink), callbacks, self, NULL);
   g_free (callbacks);
 
+  /*
+   *If using async pause, when no buffer to appsink or the first buffer appears long after elementary stream buffers,
+   *appsink never transit to PASUED or PLAYING which make pipeline unable to PLAYING. So we disable "async"
+   */
+  g_object_set (G_OBJECT (appsink), "async", FALSE, NULL);
   gst_bin_add (GST_BIN(priv->pipeline), appsink);
 
   if (!(sinkpad = gst_element_get_static_pad (appsink, "sink"))) {
--- src/engine-dvb-generic.c
+++ src/engine-dvb-generic.c
+#include <string.h>
+#include <stdio.h>
+#include <gst/gst.h>
+#include <gst/interfaces/xoverlay.h>
+/* for the volume property */
+#include <gst/interfaces/streamvolume.h>
+#include <gst/app/gstappsink.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <glib/gprintf.h>
+#include "umms-common.h"
+#include "umms-debug.h"
+#include "umms-error.h"
+#include "umms-resource-manager.h"
+#include "engine-dvb-generic.h"
+#include "media-player-control.h"
+#include "param-table.h"
+
+/* add PAT, CAT, NIT, SDT, EIT to pids filter for dvbsrc */
+#define INIT_PIDS "0:1:16:17:18"
+#define TEST_PIDS "0:257:1110:1120"
+#define DVB_SRC
+
+static void media_player_control_init (MediaPlayerControl* iface);
+
+G_DEFINE_TYPE_WITH_CODE (DvbGPlayer, dvb_Gplayer, G_TYPE_OBJECT,
+    G_IMPLEMENT_INTERFACE (TYPE_MEDIA_PLAYER_CONTROL, media_player_control_init))
+
+#define PLAYER_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), DVB_TYPE_GPLAYER, DvbGPlayerPrivate))
+
+#define GET_PRIVATE(o) ((DvbGPlayer *)o)->priv
+
+#define RESET_STR(str) \
+     if (str) {       \
+       g_free(str);   \
+       str = NULL;    \
+     }
+
+#define TEARDOWN_ELEMENT(ele)                      \
+    if (ele) {                                     \
+      gst_element_set_state (ele, GST_STATE_NULL); \
+      g_object_unref (ele);                        \
+      ele = NULL;                                  \
+    }
+
+#define INVALID_PLANE_ID -1
+
+static const gchar *gst_state[] = {
+  "GST_STATE_VOID_PENDING",
+  "GST_STATE_NULL",
+  "GST_STATE_READY",
+  "GST_STATE_PAUSED",
+  "GST_STATE_PLAYING"
+};
+
+struct _DvbGPlayerPrivate {
+
+  GstElement *pipeline;
+  GstElement *source;
+  GstElement *tsdemux;
+  GstElement *vsink;
+  GstElement *asink;
+  GstElement *mq;
+  GstElement *tsfilesink;
+
+  gchar *uri;
+  gint  seekable;
+
+  //UMMS defined player state
+  PlayerState player_state;//current state
+  PlayerState pending_state;//target state, for async state change(*==>PlayerStatePaused, PlayerStateNull/Stopped==>PlayerStatePlaying)
+
+  gboolean is_live;
+  gboolean target_initialized;
+
+  //XWindow target stuff
+  gboolean xwin_initialized;
+  gint     target_type;
+  Window   app_win_id;//top-level window
+  Window   video_win_id;
+  Display  *disp;
+  GThread  *event_thread;
+  gboolean event_thread_running;
+  
+  //resource management
+  UmmsResourceManager *res_mngr;//no need to unref, since it is global singleton.
+  GList    *res_list;
+  gboolean resource_prepared;
+  //flags to indicate resource needed by uri, should be reset before setting a new uri.
+  gboolean has_video;
+  gint     hw_viddec;//number of HW viddec needed
+  gboolean has_audio;
+  gint     hw_auddec;//number of HW auddec needed
+  gboolean has_sub;//FIXME: what resource needed by subtitle?
+
+  /* Use it to buffer the tag of the stream. */
+  GstTagList *tag_list;
+  gchar *title;
+  gchar *artist;
+
+  GList *elements;//decodarble and audio/video sink element factory
+  guint32  elements_cookie;
+
+  //current program recording
+  gboolean recording;
+  gchar *file_location;
+  GstPad *request_pad;
+
+  //associated data channel
+  gchar *ip;
+  gint  port;
+};
+
+static gboolean _stop_pipe (MediaPlayerControl *control);
+static gboolean dvb_player_set_video_size (MediaPlayerControl *self, guint x, guint y, guint w, guint h);
+static gboolean create_xevent_handle_thread (MediaPlayerControl *self);
+static gboolean destroy_xevent_handle_thread (MediaPlayerControl *self);
+static void release_resource (MediaPlayerControl *self);
+static gboolean dvb_player_set_subtitle_uri(MediaPlayerControl *player, gchar *suburi);
+static void pad_added_cb (GstElement *element, GstPad *pad, gpointer data);
+static void no_more_pads_cb (GstElement *element, gpointer data);
+static gboolean autoplug_pad(DvbGPlayer *player, GstPad *pad, gint chain_type);
+static GstPad *link_multiqueue (DvbGPlayer *player, GstPad *pad);
+static void update_elements_list (DvbGPlayer *player);
+static gboolean autoplug_dec_element (DvbGPlayer *player, GstElement * element);
+static gboolean link_sink (DvbGPlayer *player, GstPad *pad);
+static GstPad *get_sink_pad (GstElement * element);
+static gboolean start_recording (MediaPlayerControl *self);
+static gboolean stop_recording (MediaPlayerControl *self);
+GstElement *create_video_bin (void);
+GstElement *create_audio_bin (void);
+
+
+enum {
+  CHAIN_TYPE_VIDEO,
+  CHAIN_TYPE_AUDIO,
+  CHAIN_TYPE_SUB
+};
+
+#define DVBGT_PARAMS_NUM 8
+const gchar *dvbGt_param_name[] = {
+ "modulation",
+ "trans-mode",
+ "bandwidth",
+ "frequency",
+ "code-rate-lp",
+ "code-rate-hp",
+ "guard",
+ "hierarchy"
+};
+
+guint dvbGt_param_val[DVBGT_PARAMS_NUM] = {0, };
+
+/*
+ * URI pattern: 
+ * dvb://?program-number=x&type=x&modulation=x&trans-mod=x&bandwidth=x&frequency=x&code-rate-lp=x&
+ * code-rate-hp=x&guard=x&hierarchy=x
+ */
+enum dvb_type {
+ DVB_T,
+ DVB_C,
+ DVB_S,
+ DVB_TYPE_NUM
+};
+
+static gchar *dvb_type_name[] = {
+ "DVB-T",
+ "DVB-C",
+ "DVB-S"
+};
+
+static gboolean 
+set_properties(DvbGPlayer *player, const gchar *location)
+{
+  gint i;
+  gboolean ret = FALSE;
+  gchar **part = NULL;
+  gchar **params = NULL;
+  gchar *format = NULL;
+  gint program_num;
+  gint type;
+  gboolean invalid_params = FALSE;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (player);
+
+  g_return_val_if_fail (location, FALSE);
+  UMMS_DEBUG ("location = '%s'", location);
+
+  if (!priv->source || !priv->tsdemux) 
+    goto out;
+
+  if (!(part = g_strsplit (location, "?", 0))) {
+    UMMS_DEBUG ("splitting location failed");
+    goto out;
+  }
+
+  if (!(params = g_strsplit (part[1], "&", 0))) {
+    UMMS_DEBUG ("splitting params failed");
+    goto out;
+  }
+
+  if ((0 == sscanf (params[1], "type=%d", &type))) {
+    UMMS_DEBUG ("Invalid dvb type string: %s", params[1]);
+    invalid_params = TRUE;
+    goto out;
+  }
+
+  if (!(type >= 0 && type < DVB_TYPE_NUM)) {
+    UMMS_DEBUG ("Invalid dvb type: %d", type);
+    invalid_params = TRUE;
+    goto out;
+  }
+
+  UMMS_DEBUG ("Setting %s properties", dvb_type_name[type]);
+
+  //setting dvbsrc properties
+  for (i = 0; i < DVBGT_PARAMS_NUM; i++) {
+    UMMS_DEBUG ("dvbGt_param_name[%d]=%s", i, dvbGt_param_name[i]);
+    format = g_strconcat (dvbGt_param_name[i], "=%u", NULL);
+    sscanf (params[i+2], format, &dvbGt_param_val[i]);
+    g_free (format);
+    g_object_set (priv->source, dvbGt_param_name[i],  dvbGt_param_val[i], NULL);
+    UMMS_DEBUG ("Setting param: %s=%u", dvbGt_param_name[i], dvbGt_param_val[i]);
+  }
+
+  //setting program number
+  sscanf (params[0], "program-number=%d", &program_num);
+  g_object_set (priv->tsdemux, "program-number",  program_num, NULL);
+  UMMS_DEBUG ("Setting program-number: %d", program_num);
+
+  ret = TRUE;
+
+out:
+  if (part)
+    g_strfreev (part);
+  if (params)
+    g_strfreev (params);
+
+  if (invalid_params) {
+    UMMS_DEBUG ("Incorrect params string");
+  }
+    
+  if (!ret) {
+    UMMS_DEBUG ("failed");
+  }
+  return ret;
+}
+
+static gboolean
+dvb_player_parse_uri (DvbGPlayer *player, const gchar *uri)
+{
+  gboolean ret = TRUE;
+  gchar *protocol = NULL;
+  gchar *location = NULL;
+
+  g_return_val_if_fail (uri, FALSE);
+
+  protocol = gst_uri_get_protocol (uri);
+
+  if (strcmp (protocol, "dvb") != 0) {
+    ret = FALSE;
+  } else {
+    location = gst_uri_get_location (uri);
+
+    if (location != NULL) {
+      ret = set_properties (player, location);
+    } else
+      ret = FALSE;
+  }
+
+  if (protocol)
+    g_free (protocol);
+  if (location)
+    g_free (location);
+
+  return ret;
+}
+
+static gboolean
+dvb_Gplayer_set_uri (MediaPlayerControl *self,
+                    const gchar           *uri)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  g_return_val_if_fail (uri, FALSE);
+
+  UMMS_DEBUG ("SetUri called: old = %s new = %s",
+              priv->uri,
+              uri);
+
+  if (priv->player_state != PlayerStateNull) {
+    UMMS_DEBUG ("Failed, can only set uri on Null state");
+    return FALSE;
+  }
+
+  if (priv->uri) {
+    g_free (priv->uri);
+  }
+
+  priv->uri = g_strdup (uri);
+
+#ifdef DVB_SRC
+  return dvb_player_parse_uri (DVB_GPLAYER (self), uri); 
+#else
+  return TRUE;
+#endif
+}
+
+static gboolean
+get_video_rectangle (MediaPlayerControl *self, gint *ax, gint *ay, gint *w, gint *h, gint *rx, gint *ry)
+{
+  XWindowAttributes video_win_attr, app_win_attr;
+  gint app_x, app_y;
+  Window junkwin;
+  Status status;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  status = XGetWindowAttributes (priv->disp, priv->app_win_id, &app_win_attr);
+  if (!status) {
+    UMMS_DEBUG ("Get top-level window attributes failed");
+    return FALSE;
+  }
+  status = XGetWindowAttributes (priv->disp, priv->video_win_id, &video_win_attr);
+  if (!status) {
+    UMMS_DEBUG ("Get top-level window attributes failed");
+    return FALSE;
+  }
+
+  (void) XTranslateCoordinates (priv->disp, priv->app_win_id, app_win_attr.root, 
+      -app_win_attr.border_width,
+      -app_win_attr.border_width,
+      &app_x, &app_y, &junkwin);
+  UMMS_DEBUG ("app window app_absolute_x = %d, app_absolute_y = %d", app_x, app_y);
+
+  (void) XTranslateCoordinates (priv->disp, priv->video_win_id, video_win_attr.root, 
+      -video_win_attr.border_width,
+      -video_win_attr.border_width,
+      ax, ay, &junkwin);
+
+  UMMS_DEBUG ("video window video_absolute_x = %d, video_absolute_y = %d", *ax, *ay);
+
+  *rx = *ax - app_x;
+  *ry = *ay - app_y;
+  *w = video_win_attr.width;
+  *h = video_win_attr.height;
+  UMMS_DEBUG ("video window video_relative_x = %d, video_relative_y = %d", *rx, *ry);
+  UMMS_DEBUG ("video w=%d,y=%d", *w, *h);
+  return TRUE;
+}
+
+static gboolean
+cutout (MediaPlayerControl *self, gint x, gint y, gint w, gint h)
+{
+  Atom property;
+  gchar data[256];
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  property = XInternAtom (priv->disp,"_MUTTER_HINTS",0);
+  if (!property) {
+    UMMS_DEBUG ("XInternAtom failed");
+    return FALSE;
+  }
+
+  g_sprintf (data, "cross-tv-cutout-x=%d:cross-tv-cutout-y=%d:cross-tv-cutout-width=%d:"
+             "cross-tv-cutout-height=%d:cross-tv-half-trans=0:cross-tv-full-window=0", x, y, w, h);
+
+  UMMS_DEBUG ("Hints to mtv-mutter = \"%s\"", data);
+
+  XChangeProperty(priv->disp, priv->app_win_id, property, XA_STRING, 8, PropModeReplace,
+                  (unsigned char *)data, strlen(data));
+  return TRUE;
+}
+
+
+static Window 
+get_app_win (MediaPlayerControl *self, Window win)
+{
+
+  Window root_win, parent_win, grandparent_win;
+  unsigned int num_children;
+  Window *child_list;
+
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  Display *dpy = priv->disp;
+
+  if (!XQueryTree(dpy, win, &root_win, &parent_win, &child_list,
+        &num_children)) {
+    UMMS_DEBUG("Can't query window(%lx)'s parent.", win);
+    return 0;
+  }
+  UMMS_DEBUG("root=(%lx),window(%lx)'s parent = (%lx)", root_win, win, parent_win);
+  if (child_list) XFree((gchar *)child_list);
+  if (root_win == parent_win) {
+    UMMS_DEBUG("Parent is root, so we got the app window(%lx)", win);
+    return win;
+  }
+
+  if (!XQueryTree(dpy, parent_win, &root_win, &grandparent_win, &child_list,
+        &num_children)) {
+    UMMS_DEBUG("Can't query window(%lx)'s grandparent.", win);
+    return 0;
+  }
+  if (child_list) XFree((gchar *)child_list);
+  UMMS_DEBUG("root=(%lx),window(%lx)'s grandparent = (%lx)", root_win, win, grandparent_win);
+
+  if (grandparent_win == root_win) {
+    UMMS_DEBUG("Grandpa is root, so we got the app window(%lx)", win);
+    return win;
+  } else {
+    return get_app_win (self, parent_win);
+  }
+}
+
+static gboolean
+unset_xwindow_target (MediaPlayerControl *self)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  if (!priv->xwin_initialized)
+    return TRUE;
+
+  destroy_xevent_handle_thread (self);
+  priv->xwin_initialized = FALSE;
+  return TRUE;
+}
+
+static void
+dvb_player_handle_xevents (MediaPlayerControl *control)
+{
+  XEvent e;
+  gint x,y,w,h,rx,ry;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (control);
+
+  g_return_if_fail (control);
+
+  /* Handle Expose */
+  while (XCheckWindowEvent (priv->disp,
+          priv->app_win_id, StructureNotifyMask, &e)) {
+    switch (e.type) {
+      case ConfigureNotify:
+        get_video_rectangle (control, &x, &y, &w, &h, &rx, &ry);
+        cutout (control, rx, ry, w, h);
+        dvb_player_set_video_size (control, x, y, w, h);
+        UMMS_DEBUG ("Got ConfigureNotify, video window abs_x=%d,abs_y=%d,w=%d,y=%d", x, y, w, h);
+        break;
+      default:
+        break;
+    }
+  }
+}
+
+static gpointer
+dvb_player_event_thread (MediaPlayerControl* control)
+{
+
+  DvbGPlayerPrivate *priv = GET_PRIVATE (control);
+
+  UMMS_DEBUG ("Begin");
+  while (priv->event_thread_running) {
+
+    if (priv->app_win_id) {
+      dvb_player_handle_xevents (control);
+    }
+    /* FIXME: do we want to align this with the framerate or anything else? */
+    g_usleep (G_USEC_PER_SEC / 20);
+
+  }
+
+  UMMS_DEBUG ("End");
+  return NULL;
+}
+
+static gboolean
+create_xevent_handle_thread (MediaPlayerControl *self)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  UMMS_DEBUG ("Begin");
+  if (!priv->event_thread) {
+      /* Setup our event listening thread */
+      UMMS_DEBUG ("run xevent thread");
+      priv->event_thread_running = TRUE;
+      priv->event_thread = g_thread_create (
+          (GThreadFunc) dvb_player_event_thread, self, TRUE, NULL);
+  }
+  return TRUE;
+}
+
+static gboolean
+destroy_xevent_handle_thread (MediaPlayerControl *self)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  UMMS_DEBUG ("Begin");
+  if (priv->event_thread) {
+      priv->event_thread_running = FALSE;
+      g_thread_join (priv->event_thread);
+      priv->event_thread = NULL;
+  }
+  UMMS_DEBUG ("End");
+  return TRUE;
+}
+
+
+/*
+ * To get the top level window according to subwindow.
+ * Some prerequisites should be satisfied:
+ * 1. The X server uses 29 bits(i.e. bit1--bit29) to represents a window id.
+ * 2. The X server uses bit22--bit29 to represents a connection/client, it means X server supports 256 connections/clients at maximum.
+ * 3. The top-level window and subwindow is requested from the same connection.
+ * 1 and 2 are the case of xorg server.
+ * 3 is always satisfied, unless subwindow is requested from a process which is not the same process hosting the top-level window.
+*/
+static Window get_top_level_win (MediaPlayerControl *self, Window sub_win)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  Display *disp = priv->disp;
+  Window root_win, parent_win, cur_win;
+  unsigned int num_children;
+  Window *child_list = NULL;
+  Window top_win = 0;
+  gboolean done = FALSE;
+
+  if (!disp)
+    return 0;
+
+  printf ("============%s:Begin, sub_win=%lx ==========\n", __FUNCTION__, sub_win);
+#define CLIENT_MASK (0x1fe00000)
+#define FROM_THE_SAME_PROC(w1,w2) ((w1&CLIENT_MASK) == (w2&CLIENT_MASK))
+
+  cur_win = sub_win;
+  while (!done) {
+    if (!XQueryTree(disp, cur_win, &root_win, &parent_win, &child_list,&num_children)) {
+      UMMS_DEBUG ("Can't query window tree.");
+      return 0;
+    }
+
+    UMMS_DEBUG ("cur_win(%lx), parent_win(%lx)", cur_win, parent_win);
+    if (child_list) XFree((char *)child_list);
+
+    if (!FROM_THE_SAME_PROC(cur_win, parent_win)){
+      UMMS_DEBUG ("Got the top-level window(%lx)", cur_win);
+      top_win = cur_win;
+      done = TRUE;
+      break;
+    };
+    cur_win = parent_win;
+  }
+  printf ("============%s:End==========\n", __FUNCTION__);
+  return top_win;
+}
+
+static gboolean setup_datacopy_target (MediaPlayerControl *self, GHashTable *params)
+{
+  gchar *rect = NULL;
+  GValue *val = NULL;
+  GstElement *shmvbin = NULL;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  GstElement **cur_vsink_p = &priv->vsink;
+  
+  UMMS_DEBUG ("setting up datacopy target");
+  shmvbin = gst_element_factory_make ("shmvidrendbin", NULL);
+  if (!shmvbin) {
+    UMMS_DEBUG ("Making \"shmvidrendbin\" failed");
+    return FALSE;
+  }
+  gst_object_ref_sink (shmvbin);
+
+  val = g_hash_table_lookup (params, TARGET_PARAM_KEY_RECTANGLE);
+  if (val) {
+    rect = (gchar *)g_value_get_string (val);
+    UMMS_DEBUG ("setting rectangle = '%s'", rect);
+    g_object_set (shmvbin, "rectangle", rect, NULL);
+  }
+
+  gst_object_replace ((GstObject **)cur_vsink_p, (GstObject *)shmvbin);
+  UMMS_DEBUG ("Set \"shmvidrendbin\" to dvbplayer");
+
+  if (shmvbin)
+    gst_object_unref (shmvbin);
+  return TRUE;
+}
+
+static int x_print_error(
+    Display *dpy,
+    XErrorEvent *event,
+    FILE *fp)
+{
+  char buffer[BUFSIZ];
+  char mesg[BUFSIZ];
+  char number[32];
+  const char *mtype = "XlibMessage";
+  XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+  XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+  (void) fprintf(fp, "%s:  %s\n  ", mesg, buffer);
+  XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+      mesg, BUFSIZ);
+  (void) fprintf(fp, mesg, event->request_code);
+  if (event->request_code < 128) {
+    sprintf(number, "%d", event->request_code);
+    XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+  }
+
+  (void) fprintf(fp, " (%s)\n", buffer);
+  if (event->request_code >= 128) {
+    XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+        mesg, BUFSIZ);
+    fputs("  ", fp);
+    (void) fprintf(fp, mesg, event->minor_code);
+
+    fputs("\n", fp);
+  }
+  if (event->error_code >= 128) {
+    strcpy(buffer, "Value");
+    XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+    if (mesg[0]) {
+      fputs("  ", fp);
+      (void) fprintf(fp, mesg, event->resourceid);
+      fputs("\n", fp);
+    }
+
+  } else if ((event->error_code == BadWindow) ||
+      (event->error_code == BadPixmap) ||
+      (event->error_code == BadCursor) ||
+      (event->error_code == BadFont) ||
+      (event->error_code == BadDrawable) ||
+      (event->error_code == BadColor) ||
+      (event->error_code == BadGC) ||
+      (event->error_code == BadIDChoice) ||
+      (event->error_code == BadValue) ||
+      (event->error_code == BadAtom)) {
+    if (event->error_code == BadValue)
+      XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+          mesg, BUFSIZ);
+    else if (event->error_code == BadAtom)
+      XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+          mesg, BUFSIZ);
+    else
+      XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+          mesg, BUFSIZ);
+    fputs("  ", fp);
+    (void) fprintf(fp, mesg, event->resourceid);
+    fputs("\n", fp);
+  }
+  XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+      mesg, BUFSIZ);
+  fputs("  ", fp);
+  (void) fprintf(fp, mesg, event->serial);
+  XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+      mesg, BUFSIZ);
+  fputs("\n  ", fp);
+  if (event->error_code == BadImplementation) return 0;
+  return 1;
+}
+
+//Mostly the same as default handler, but not exit process.
+static int xerror_handler (
+	Display *dpy,
+	XErrorEvent *event)
+{
+    return x_print_error (dpy, event, stderr);
+}
+
+
+static gboolean setup_xwindow_target (MediaPlayerControl *self, GHashTable *params)
+{
+  GValue *val;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  val = g_hash_table_lookup (params, "window-id");
+  if (!val) {
+    UMMS_DEBUG ("no window-id");
+    return FALSE;
+  }
+
+  priv->video_win_id = (Window)g_value_get_int (val);
+  priv->target_type = XWindow;
+
+  return TRUE;
+}
+
+static gboolean
+unset_target (MediaPlayerControl *self)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  if (!priv->target_initialized)
+    return TRUE;
+
+  /*
+   *For DataCopy and ReservedType0, nothing need to do here.
+   */
+  switch (priv->target_type) {
+    case XWindow:
+      unset_xwindow_target (self);
+      break;
+    case DataCopy:
+      break;
+    case Socket:
+      g_assert_not_reached ();
+      break;
+    case ReservedType0:
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
+  }
+
+  priv->target_type = TargetTypeInvalid;
+  priv->target_initialized = FALSE;
+  return TRUE;
+}
+
+static gboolean
+dvb_Gplayer_set_target (MediaPlayerControl *self, gint type, GHashTable *params)
+{
+  gboolean ret = TRUE;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  /*
+   * Set target can only happen at Null or Stopped. Two reasons:
+   * 1. Gstreamer don't support switching sink on the fly.
+   * 2. PlayerStateNull/PlayerStateStopped means all target related resources have been released.
+   *    It is more convenience for resource management implementing.
+   */
+  if (priv->player_state != PlayerStateNull && priv->player_state != PlayerStateStopped) {
+    UMMS_DEBUG ("Ignored, can only set target at PlayerStateNull or PlayerStateStopped");
+    return FALSE;
+  }
+
+  if (!priv->pipeline) {
+    UMMS_DEBUG ("Engine not loaded, reason may be SetUri not invoked");
+    return FALSE;
+  }
+
+  switch (type) {
+    case XWindow:
+      ret = setup_xwindow_target (self, params);
+      break;
+    case DataCopy:
+    case Socket:
+    case ReservedType0:
+    default:
+      ret = FALSE;
+      break;
+  }
+
+  if (ret) {
+    priv->target_type = type;
+  }
+  return ret;
+}
+
+static gboolean 
+prepare_plane (MediaPlayerControl *self)
+{
+  GstElement *vsink_bin;
+  gint plane;
+  gboolean ret = TRUE;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  vsink_bin = priv->vsink;
+  if (vsink_bin) {
+    if (g_object_class_find_property (G_OBJECT_GET_CLASS (vsink_bin), "gdl-plane") == NULL) {
+      UMMS_DEBUG ("vsink has no gdl-plane property, which means target type is not XWindow or ReservedType0");
+      return ret;
+    }
+
+    g_object_get (G_OBJECT(vsink_bin), "gdl-plane", &plane, NULL);
+
+    //request plane resource
+    ResourceRequest req = {ResourceTypePlane, plane};
+    Resource *res = NULL;
+
+    res = umms_resource_manager_request_resource (priv->res_mngr, &req);
+
+    if (!res) {
+      UMMS_DEBUG ("Failed");
+      ret = FALSE;
+    } else if (plane != res->handle) {
+      g_object_set (G_OBJECT(vsink_bin), "gdl-plane", res->handle, NULL);
+      UMMS_DEBUG ("Plane changed '%d'==>'%d'", plane,  res->handle);
+    } else {
+      //Do nothing;  
+    }
+
+    priv->res_list = g_list_append (priv->res_list, res);
+  }
+
+  return ret;
+}
+
+//both Xwindow and ReservedType0 target use ismd_vidrend_sink, so that need clock.
+#define NEED_CLOCK(target_type) \
+  ((target_type == XWindow || target_type == ReservedType0)?TRUE:FALSE)
+
+#define REQUEST_RES(self, t, p, e_msg)                                        \
+  do{                                                                         \
+    DvbGPlayerPrivate *priv = GET_PRIVATE (self);                              \
+    ResourceRequest req = {0,};                                               \
+    Resource *res = NULL;                                                     \
+    req.type = t;                                                             \
+    req.preference = p;                                                       \
+    res = umms_resource_manager_request_resource (priv->res_mngr, &req);      \
+    if (!res) {                                                               \
+      release_resource(self);                                                 \
+      media_player_control_emit_error (self,                            \
+                                             UMMS_RESOURCE_ERROR_NO_RESOURCE, \
+                                             e_msg);                          \
+      return FALSE;                                                           \
+    }                                                                         \
+    priv->res_list = g_list_append (priv->res_list, res);                     \
+    }while(0)
+
+  
+static gboolean
+request_resource (MediaPlayerControl *self)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  if (priv->resource_prepared)
+    return TRUE;
+  
+  //FIXME:For now, just request HW clock and Tuner resources. How to know we need HW decoder?
+  REQUEST_RES(self, ResourceTypeHwClock, INVALID_RES_HANDLE, "No HW clock resource");
+  REQUEST_RES(self, ResourceTypeTuner, INVALID_RES_HANDLE, "No tuner resource");
+
+  priv->resource_prepared = TRUE;
+  return TRUE;
+}
+
+static void
+release_resource (MediaPlayerControl *self)
+{
+  GList *g;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  for (g = priv->res_list; g; g = g->next) {
+    Resource *res = (Resource *) (g->data);
+    umms_resource_manager_release_resource (priv->res_mngr, res);
+  }
+  g_list_free (priv->res_list);
+  priv->res_list = NULL;
+  priv->resource_prepared = FALSE;
+
+  return;
+}
+
+#if 0
+//Unref returned clock after usage
+static GstClock * 
+get_hw_clock(void)
+{
+  GstClock* clock = NULL;
+  GstElement *vsink = NULL;
+
+  UMMS_DEBUG ("Begin");
+  vsink = gst_element_factory_make ("ismd_vidrend_sink", NULL);
+  if (!vsink)
+    return NULL;
+
+  clock = gst_element_provide_clock (vsink);
+  
+  if (clock)
+    g_object_ref (clock);
+
+  g_object_unref (vsink);
+  UMMS_DEBUG ("End");
+
+  return clock;
+}
+#endif
+
+static gboolean
+dvb_Gplayer_play (MediaPlayerControl *self)
+{
+    DvbGPlayerPrivate *priv = GET_PRIVATE(self);
+
+    if (request_resource(self)) {
+      if (gst_element_set_state(priv->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+        UMMS_DEBUG ("Set pipeline to paused failed");
+        return FALSE;
+      }
+    }
+    return TRUE;
+}
+
+static gboolean
+_stop_pipe (MediaPlayerControl *control)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (control);
+
+  if (priv->recording) {
+    stop_recording (control);
+  }
+
+  if (gst_element_set_state(priv->pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) {
+    UMMS_DEBUG ("Unable to set NULL state");
+    return FALSE;
+  }
+
+  release_resource (control);
+
+  UMMS_DEBUG ("gstreamer engine stopped");
+  return TRUE;
+}
+
+static gboolean
+dvb_Gplayer_stop (MediaPlayerControl *self)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  PlayerState old_state;
+
+  if (!_stop_pipe (self))
+    return FALSE;
+
+  old_state = priv->player_state;
+  priv->player_state = PlayerStateStopped;
+
+  if (old_state != priv->player_state) {
+    media_player_control_emit_player_state_changed (self, old_state, priv->player_state);
+  }
+  media_player_control_emit_stopped (self);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_set_video_size (MediaPlayerControl *self,
+    guint x, guint y, guint w, guint h)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  GstElement *pipeline = priv->pipeline;
+  gboolean ret;
+  GstElement *vsink_bin;
+
+  g_return_val_if_fail (pipeline, FALSE);
+  UMMS_DEBUG ("invoked");
+
+  //We use ismd_vidrend_bin as video-sink, so we can set rectangle property.
+  g_object_get (G_OBJECT(pipeline), "video-sink", &vsink_bin, NULL);
+  if (vsink_bin) {
+    gchar *rectangle_des = NULL;
+
+    rectangle_des = g_strdup_printf ("%u,%u,%u,%u", x, y, w, h);
+    UMMS_DEBUG ("set rectangle damension :'%s'", rectangle_des);
+    g_object_set (G_OBJECT(vsink_bin), "rectangle", rectangle_des, NULL);
+    g_free (rectangle_des);
+    gst_object_unref (vsink_bin);
+    ret = TRUE;
+  } else {
+    UMMS_DEBUG ("Get video-sink failed");
+    ret = FALSE;
+  }
+
+  return ret;
+}
+
+static gboolean
+dvb_player_get_video_size (MediaPlayerControl *self,
+    guint *w, guint *h)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  GstElement *pipeline = priv->pipeline;
+  guint x[1], y[1];
+  gboolean ret;
+  GstElement *vsink_bin;
+
+  g_return_val_if_fail (pipeline, FALSE);
+  UMMS_DEBUG ("invoked");
+  g_object_get (G_OBJECT(pipeline), "video-sink", &vsink_bin, NULL);
+  if (vsink_bin) {
+    gchar *rectangle_des = NULL;
+    g_object_get (G_OBJECT(vsink_bin), "rectangle", &rectangle_des, NULL);
+    sscanf (rectangle_des, "%u,%u,%u,%u", x, y, w, h);
+    UMMS_DEBUG ("got rectangle damension :'%u,%u,%u,%u'", *x, *y, *w, *h);
+    gst_object_unref (vsink_bin);
+    ret = TRUE;
+  } else {
+    UMMS_DEBUG ("Get video-sink failed");
+    ret = FALSE;
+  }
+  return ret;
+}
+
+static gboolean
+dvb_player_is_seekable (MediaPlayerControl *self, gboolean *seekable)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gboolean res = FALSE;
+  gint old_seekable;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (seekable != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+
+  if (priv->uri == NULL)
+    return FALSE;
+
+  old_seekable = priv->seekable;
+
+  if (priv->seekable == -1) {
+    GstQuery *query;
+
+    query = gst_query_new_seeking (GST_FORMAT_TIME);
+    if (gst_element_query (pipeline, query)) {
+      gst_query_parse_seeking (query, NULL, &res, NULL, NULL);
+      UMMS_DEBUG ("seeking query says the stream is%s seekable", (res) ? "" : " not");
+      priv->seekable = (res) ? 1 : 0;
+    } else {
+      UMMS_DEBUG ("seeking query failed, set seekable according to is_live flag");
+      priv->seekable = priv->is_live ? FALSE : TRUE;
+    }
+    gst_query_unref (query);
+  }
+
+  if (priv->seekable != -1) {
+    *seekable = (priv->seekable != 0);
+  }
+
+  UMMS_DEBUG ("stream is%s seekable", (*seekable) ? "" : " not");
+  return TRUE;
+}
+
+static gboolean
+dvb_player_set_volume (MediaPlayerControl *self, gint vol)
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  gdouble volume;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  UMMS_DEBUG ("invoked");
+
+  volume = CLAMP ((((gdouble)vol) / 100), 0.0, 1.0);
+  UMMS_DEBUG ("set volume to = %f", volume);
+  gst_stream_volume_set_volume (GST_STREAM_VOLUME (pipeline),
+      GST_STREAM_VOLUME_FORMAT_CUBIC,
+      volume);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_volume (MediaPlayerControl *self, gint *volume)
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  gdouble vol;
+
+  *volume = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  UMMS_DEBUG ("invoked");
+
+  vol = gst_stream_volume_get_volume (GST_STREAM_VOLUME (pipeline),
+        GST_STREAM_VOLUME_FORMAT_CUBIC);
+
+  *volume = vol * 100;
+  UMMS_DEBUG ("cur volume=%f(double), %d(int)", vol, *volume);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_has_video (MediaPlayerControl *self, gboolean *has_video)
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  gint n_video;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  UMMS_DEBUG ("invoked");
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &n_video, NULL);
+  UMMS_DEBUG ("'%d' videos in stream", n_video);
+  *has_video = (n_video > 0) ? (TRUE) : (FALSE);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_has_audio (MediaPlayerControl *self, gboolean *has_audio)
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  gint n_audio;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  UMMS_DEBUG ("invoked");
+
+  g_object_get (G_OBJECT (pipeline), "n-audio", &n_audio, NULL);
+  UMMS_DEBUG ("'%d' audio tracks in stream", n_audio);
+  *has_audio = (n_audio > 0) ? (TRUE) : (FALSE);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_support_fullscreen (MediaPlayerControl *self, gboolean *support_fullscreen)
+{
+  //We are using ismd_vidrend_bin, so this function always return TRUE.
+  *support_fullscreen = TRUE;
+  return TRUE;
+}
+
+static gboolean
+dvb_player_is_streaming (MediaPlayerControl *self, gboolean *is_streaming)
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  UMMS_DEBUG ("invoked");
+
+  g_return_val_if_fail (priv->uri, FALSE);
+  /*For now, we consider live source to be streaming source , hence unseekable.*/
+  *is_streaming = priv->is_live;
+  UMMS_DEBUG ("uri:'%s' is %s streaming source", priv->uri, (*is_streaming) ? "" : "not");
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_player_state (MediaPlayerControl *self,
+    gint *state)
+{
+  DvbGPlayerPrivate *priv;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (state != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+
+  *state = priv->player_state;
+  return TRUE;
+}
+
+static gboolean 
+dvb_player_get_current_audio (MediaPlayerControl *self, gint *cur_audio)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint c_audio = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  g_object_get (G_OBJECT (pipeline), "current-audio", &c_audio, NULL);
+  UMMS_DEBUG ("the current audio stream is %d", c_audio);
+
+  *cur_audio = c_audio;
+
+  return TRUE;
+}
+
+static gboolean 
+dvb_player_set_current_video (MediaPlayerControl *self, gint cur_video)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *ele = NULL;
+  gint n_video = -1;
+  gchar *program_num = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  ele = priv->tsdemux;
+  g_return_val_if_fail (GST_IS_ELEMENT (ele), FALSE);
+
+  program_num = g_strdup_printf("%d", cur_video);
+  UMMS_DEBUG ("set program-numbers begin, program-numbers = %s", program_num);
+  //g_object_set (G_OBJECT (tsparse), "program-numbers", program_num, NULL);
+  g_object_set (G_OBJECT (ele), "program-number", cur_video, NULL);
+  g_free (program_num);
+  UMMS_DEBUG ("set program-numbers end");
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_set_current_audio (MediaPlayerControl *self, gint cur_audio)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint n_audio = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  /* Because the playbin2 set_property func do no check the return value,
+     we need to get the total number and check valid for cur_audio ourselves.*/
+  g_object_get (G_OBJECT (pipeline), "n-audio", &n_audio, NULL);
+  UMMS_DEBUG ("The total audio numeber is %d, we want to set to %d", n_audio, cur_audio);
+  if((cur_audio< 0) || (cur_audio >= n_audio)) {
+    UMMS_DEBUG ("The audio we want to set is %d, invalid one.", cur_audio);
+    return FALSE;
+  }
+
+  g_object_set (G_OBJECT (pipeline), "current-audio", cur_audio, NULL);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_video_num (MediaPlayerControl *self, gint *video_num)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint n_video = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &n_video, NULL);
+  UMMS_DEBUG ("the video number of the stream is %d", n_video);
+
+  *video_num = n_video;
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_audio_num (MediaPlayerControl *self, gint *audio_num)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint n_audio = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  g_object_get (G_OBJECT (pipeline), "n-audio", &n_audio, NULL);
+  UMMS_DEBUG ("the audio number of the stream is %d", n_audio);
+
+  *audio_num = n_audio;
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_subtitle_num (MediaPlayerControl *self, gint *sub_num)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint n_sub = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  g_object_get (G_OBJECT (pipeline), "n-text", &n_sub, NULL);
+  UMMS_DEBUG ("the subtitle number of the stream is %d", n_sub);
+
+  *sub_num = n_sub;
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_current_subtitle (MediaPlayerControl *self, gint *cur_sub)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint c_sub = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  g_object_get (G_OBJECT (pipeline), "current-text", &c_sub, NULL);
+  UMMS_DEBUG ("the current subtitle stream is %d", c_sub);
+
+  *cur_sub = c_sub;
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_set_current_subtitle (MediaPlayerControl *self, gint cur_sub)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gint n_sub = -1;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  /* Because the playbin2 set_property func do no check the return value,
+     we need to get the total number and check valid for cur_sub ourselves.*/
+  g_object_get (G_OBJECT (pipeline), "n-text", &n_sub, NULL);
+  UMMS_DEBUG ("The total subtitle numeber is %d, we want to set to %d", n_sub, cur_sub);
+  if((cur_sub < 0) || (cur_sub >= n_sub)) {
+    UMMS_DEBUG ("The subtitle we want to set is %d, invalid one.", cur_sub);
+    return FALSE;
+  }
+
+  g_object_set (G_OBJECT (pipeline), "current-text", cur_sub, NULL);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_set_mute (MediaPlayerControl *self, gint mute) 
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  UMMS_DEBUG ("set mute to = %d", mute);
+  gst_stream_volume_set_mute (GST_STREAM_VOLUME (pipeline), mute);
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_player_is_mute (MediaPlayerControl *self, gint *mute) 
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  gboolean is_mute;
+
+  *mute = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  is_mute = gst_stream_volume_get_mute (GST_STREAM_VOLUME (pipeline));
+  UMMS_DEBUG("Get the mute %d", is_mute);
+  *mute = is_mute;
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_player_set_scale_mode (MediaPlayerControl *self, gint scale_mode) 
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  GstElement *vsink_bin;
+  GParamSpec *pspec = NULL;
+  GEnumClass *eclass = NULL;
+  gboolean ret = TRUE;
+  GValue val = { 0, };
+  GEnumValue *eval;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  /* We assume that the video-sink is just ismd_vidrend_bin, because if not
+     the scale mode is not supported yet in gst sink bins. */ 
+  g_object_get (G_OBJECT(pipeline), "video-sink", &vsink_bin, NULL);
+  if (vsink_bin) {
+    pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink_bin), "scale-mode");
+    if (pspec == NULL) {
+      ret = FALSE;
+      UMMS_DEBUG("can not get the scale-mode feature");
+      goto OUT;
+    }
+
+    g_value_init (&val, pspec->value_type);
+    g_object_get_property (G_OBJECT (vsink_bin), "scale-mode", &val);
+    eclass = G_ENUM_CLASS (g_type_class_peek (G_VALUE_TYPE (&val)));
+    if (eclass == NULL) {
+      ret = FALSE;
+      goto OUT;
+    }
+
+    switch (scale_mode) {
+      case ScaleModeNoScale:
+        eval = g_enum_get_value_by_nick (eclass, "none");
+        break;
+      case ScaleModeFill:
+        eval = g_enum_get_value_by_nick (eclass, "scale2fit");
+        break;
+      case ScaleModeKeepAspectRatio:
+        eval = g_enum_get_value_by_nick (eclass, "zoom2fit");
+        break;
+      case ScaleModeFillKeepAspectRatio:
+        eval = g_enum_get_value_by_nick (eclass, "zoom2fill");
+        break;
+      default:
+        UMMS_DEBUG("Invalid scale mode: %d", scale_mode);
+        ret = FALSE;
+        goto OUT;
+    }
+
+    if (eval == NULL) {
+      ret = FALSE;
+      goto OUT;
+    }
+
+    g_value_set_enum (&val, eval->value);
+    g_object_set_property (G_OBJECT (vsink_bin), "scale-mode", &val);
+    g_value_unset (&val);
+  } else {
+    UMMS_DEBUG("No a vidrend_bin set, scale not support now!");
+    ret = FALSE;
+  }
+
+OUT:
+  if(vsink_bin)
+    gst_object_unref (vsink_bin);
+  return ret;
+}
+
+
+static gboolean
+dvb_player_get_scale_mode (MediaPlayerControl *self, gint *scale_mode)
+{
+  GstElement *pipeline;
+  DvbGPlayerPrivate *priv;
+  GstElement *vsink_bin;
+  gboolean ret = TRUE;
+  GValue val = { 0, };
+  GEnumValue *eval;
+  GParamSpec *pspec = NULL;
+  GEnumClass *eclass = NULL;
+
+  *scale_mode = ScaleModeInvalid; 
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_return_val_if_fail (GST_IS_ELEMENT (pipeline), FALSE);
+
+  /* We assume that the video-sink is just ismd_vidrend_bin, because if not
+     the scale mode is not supported yet in gst sink bins. */ 
+  g_object_get (G_OBJECT(pipeline), "video-sink", &vsink_bin, NULL);
+  if (vsink_bin) {
+    pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (vsink_bin), "scale-mode");
+    if (pspec == NULL) {
+      ret = FALSE;
+      UMMS_DEBUG("can not get the scale-mode feature");
+      goto OUT;
+    }
+
+    g_value_init (&val, pspec->value_type);
+    g_object_get_property (G_OBJECT (vsink_bin), "scale-mode", &val);
+    eclass = G_ENUM_CLASS (g_type_class_peek (G_VALUE_TYPE (&val)));
+    if (eclass == NULL) {
+      ret = FALSE;
+      goto OUT;
+    }
+
+    eval = g_enum_get_value (eclass, g_value_get_enum(&val));
+    if (eval == NULL) {
+      ret = FALSE;
+      goto OUT;
+    }
+
+    if (strcmp(eval->value_nick, "none")) {
+      *scale_mode = ScaleModeNoScale;
+      goto OUT;
+    } else if (strcmp(eval->value_nick, "scale2fit")) {
+      *scale_mode = ScaleModeFill;
+      goto OUT;
+    } else if (strcmp(eval->value_nick, "zoom2fit")) {
+      *scale_mode = ScaleModeKeepAspectRatio;
+      goto OUT;
+    } else if (strcmp(eval->value_nick, "zoom2fill")) {
+      *scale_mode = ScaleModeFillKeepAspectRatio;
+      goto OUT;
+    } else {
+      UMMS_DEBUG("Error scale mode");
+      ret = FALSE;
+    }
+  } else {
+    UMMS_DEBUG("No a vidrend_bin set, scale not support now!");
+    ret = FALSE;
+  }
+
+OUT:
+  if(vsink_bin)
+    gst_object_unref (vsink_bin);
+  return ret;
+}
+
+static gboolean
+dvb_player_get_video_codec (MediaPlayerControl *self, gint channel, gchar ** video_codec)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstTagList * tag_list = NULL;
+  gint size = 0;
+  gchar * codec_name = NULL;
+  int i;
+
+  *video_codec = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &tol_channel, NULL);
+  UMMS_DEBUG ("the video number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-video-tags", channel, &tag_list);
+  if(tag_list == NULL) {
+    UMMS_DEBUG ("No tags about stream: %d", channel);
+    return TRUE;
+  }
+
+  if(size = gst_tag_list_get_tag_size(tag_list, GST_TAG_VIDEO_CODEC) > 0) {
+    gchar *st = NULL;        
+
+    for (i = 0; i < size; ++i) {
+      if(gst_tag_list_get_string_index (tag_list, GST_TAG_VIDEO_CODEC, i, &st) && st) {
+        UMMS_DEBUG("Channel: %d provide the video codec named: %s", channel, st);
+        if(codec_name) {
+          codec_name = g_strconcat(codec_name, st);
+        } else {
+          codec_name = g_strdup(st);
+        }
+        g_free (st);  
+      }
+    }
+
+    UMMS_DEBUG("%s", codec_name);
+  }
+
+  if(codec_name)
+    *video_codec = codec_name;
+
+  if(tag_list)
+    gst_tag_list_free (tag_list);
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_Gplayer_get_audio_codec (MediaPlayerControl *self, gint channel, gchar ** audio_codec)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstTagList * tag_list = NULL;
+  gint size = 0;
+  gchar * codec_name = NULL;
+  int i;
+
+  *audio_codec = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+
+  g_object_get (G_OBJECT (pipeline), "n-audio", &tol_channel, NULL);
+  UMMS_DEBUG ("the audio number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+  
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-audio-tags", channel, &tag_list);
+  if(tag_list == NULL) {
+    UMMS_DEBUG ("No tags about stream: %d", channel);
+    return TRUE;
+  }
+
+  if(size = gst_tag_list_get_tag_size(tag_list, GST_TAG_AUDIO_CODEC) > 0) {
+    gchar *st = NULL;        
+
+    for (i = 0; i < size; ++i) {
+      if(gst_tag_list_get_string_index (tag_list, GST_TAG_AUDIO_CODEC, i, &st) && st) {
+        UMMS_DEBUG("Channel: %d provide the audio codec named: %s", channel, st);
+        if(codec_name) {
+          codec_name = g_strconcat(codec_name, st);
+        } else {
+          codec_name = g_strdup(st);
+        }
+        g_free (st);  
+      }
+    }
+
+    UMMS_DEBUG("%s", codec_name);
+  }
+
+  if(codec_name)
+    *audio_codec = codec_name;
+
+  if(tag_list)
+    gst_tag_list_free (tag_list);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_Gplayer_get_video_bitrate (MediaPlayerControl *self, gint channel, gint *video_rate)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstTagList * tag_list = NULL;
+  gint size = 0;
+  guint32 bit_rate = 0;
+
+  *video_rate = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &tol_channel, NULL);
+  UMMS_DEBUG ("the video number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+  
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-video-tags", channel, &tag_list);
+  if(tag_list == NULL) {
+    UMMS_DEBUG ("No tags about stream: %d", channel);
+    return TRUE;
+  }
+
+  if(gst_tag_list_get_uint(tag_list, GST_TAG_BITRATE, &bit_rate) && bit_rate > 0) {
+    UMMS_DEBUG ("bit rate for channel: %d is %d", channel, bit_rate);
+    *video_rate = bit_rate/1000;
+  } else if(gst_tag_list_get_uint(tag_list, GST_TAG_NOMINAL_BITRATE, &bit_rate) && bit_rate > 0) {
+    UMMS_DEBUG ("nominal bit rate for channel: %d is %d", channel, bit_rate);
+    *video_rate = bit_rate/1000;
+  } else {
+    UMMS_DEBUG ("No bit rate for channel: %d", channel);
+  }
+
+  if(tag_list)
+    gst_tag_list_free (tag_list);
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_player_get_audio_bitrate (MediaPlayerControl *self, gint channel, gint *audio_rate)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstTagList * tag_list = NULL;
+  gint size = 0;
+  guint32 bit_rate = 0;
+  
+  *audio_rate = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+
+  g_object_get (G_OBJECT (pipeline), "n-audio", &tol_channel, NULL);
+  UMMS_DEBUG ("the audio number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-audio-tags", channel, &tag_list);
+  if(tag_list == NULL) {
+    UMMS_DEBUG ("No tags about stream: %d", channel);
+    return TRUE;
+  }
+
+  if(gst_tag_list_get_uint(tag_list, GST_TAG_BITRATE, &bit_rate) && bit_rate > 0) {
+    UMMS_DEBUG ("bit rate for channel: %d is %d", channel, bit_rate);
+    *audio_rate = bit_rate/1000;
+  } else if(gst_tag_list_get_uint(tag_list, GST_TAG_NOMINAL_BITRATE, &bit_rate) && bit_rate > 0) {
+    UMMS_DEBUG ("nominal bit rate for channel: %d is %d", channel, bit_rate);
+    *audio_rate = bit_rate/1000;
+  } else {
+    UMMS_DEBUG ("No bit rate for channel: %d", channel);
+  }
+
+  if(tag_list)
+    gst_tag_list_free (tag_list);
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_player_get_encapsulation(MediaPlayerControl *self, gchar ** encapsulation)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gchar *enca_name = NULL;
+
+  *encapsulation = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+
+  if(priv->tag_list) {
+    gst_tag_list_get_string (priv->tag_list, GST_TAG_CONTAINER_FORMAT, &enca_name);
+    if(enca_name) {
+      UMMS_DEBUG("get the container name: %s", enca_name);
+      *encapsulation = enca_name;
+    } else {
+      UMMS_DEBUG("no infomation about the container.");
+    }
+  }
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_player_get_audio_samplerate(MediaPlayerControl *self, gint channel, gint * sample_rate)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstCaps *caps = NULL;
+  GstPad *pad = NULL;
+  GstStructure *s = NULL;
+  gboolean ret = TRUE;
+
+  *sample_rate = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  /* We get this kind of infomation from the caps of inputselector. */
+
+  g_object_get (G_OBJECT (pipeline), "n-audio", &tol_channel, NULL);
+  UMMS_DEBUG ("the audio number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-audio-pad", channel, &pad);
+  if(pad == NULL) {
+    UMMS_DEBUG ("No pad of stream: %d", channel);
+    return FALSE;
+  }
+
+  caps = gst_pad_get_negotiated_caps (pad);
+  if (caps) {
+    s = gst_caps_get_structure (caps, 0);
+    ret = gst_structure_get_int (s, "rate", sample_rate);
+    gst_caps_unref (caps);
+  }
+
+  if(pad)
+    gst_object_unref (pad);
+
+  return ret;
+}
+
+
+static gboolean
+dvb_player_get_video_framerate(MediaPlayerControl *self, gint channel, 
+                               gint * frame_rate_num, gint * frame_rate_denom)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstCaps *caps = NULL;
+  GstPad *pad = NULL;
+  GstStructure *s = NULL;
+  gboolean ret = TRUE;
+
+  *frame_rate_num = 0;
+  *frame_rate_denom = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  /* We get this kind of infomation from the caps of inputselector. */
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &tol_channel, NULL);
+  UMMS_DEBUG ("the video number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-video-pad", channel, &pad);
+  if(pad == NULL) {
+    UMMS_DEBUG ("No pad of stream: %d", channel);
+    return FALSE;
+  }
+
+  caps = gst_pad_get_negotiated_caps (pad);
+  if (caps) {
+    s = gst_caps_get_structure (caps, 0);
+    ret = gst_structure_get_fraction(s, "framerate", frame_rate_num, frame_rate_denom);
+    gst_caps_unref (caps);
+  }
+
+  if(pad)
+    gst_object_unref (pad);
+
+  return ret;
+}
+
+
+static gboolean
+dvb_player_get_video_resolution(MediaPlayerControl *self, gint channel, gint * width, gint * height)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstCaps *caps = NULL;
+  GstPad *pad = NULL;
+  GstStructure *s = NULL;
+
+  *width = 0;
+  *height = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  /* We get this kind of infomation from the caps of inputselector. */
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &tol_channel, NULL);
+  UMMS_DEBUG ("the video number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-video-pad", channel, &pad);
+  if(pad == NULL) {
+    UMMS_DEBUG ("No pad of stream: %d", channel);
+    return FALSE;
+  }
+
+  caps = gst_pad_get_negotiated_caps (pad);
+  if (caps) {
+    s = gst_caps_get_structure (caps, 0);
+    gst_structure_get_int (s, "width", width);
+    gst_structure_get_int (s, "height", height);
+    gst_caps_unref (caps);
+  }
+
+  if(pad)
+    gst_object_unref (pad);
+
+  return TRUE;
+}
+
+
+static gboolean
+dvb_player_get_video_aspect_ratio(MediaPlayerControl *self, gint channel, 
+                                  gint * ratio_num, gint * ratio_denom)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  int tol_channel;
+  GstCaps *caps = NULL;
+  GstPad *pad = NULL;
+  GstStructure *s = NULL;
+  gboolean ret = TRUE;
+
+  *ratio_num = 0;
+  *ratio_denom = 0;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  /* We get this kind of infomation from the caps of inputselector. */
+
+  g_object_get (G_OBJECT (pipeline), "n-video", &tol_channel, NULL);
+  UMMS_DEBUG ("the video number of the stream is %d, want to get: %d", 
+          tol_channel, channel);
+
+  if(channel >= tol_channel || channel < 0) {
+    UMMS_DEBUG ("Invalid Channel: %d", channel);
+    return FALSE;
+  }
+
+  g_signal_emit_by_name (pipeline, "get-video-pad", channel, &pad);
+  if(pad == NULL) {
+    UMMS_DEBUG ("No pad of stream: %d", channel);
+    return FALSE;
+  }
+
+  caps = gst_pad_get_negotiated_caps (pad);
+  if (caps) {
+    s = gst_caps_get_structure (caps, 0);
+    ret = gst_structure_get_fraction(s, "pixel-aspect-ratio", ratio_num, ratio_denom);
+    gst_caps_unref (caps);
+  }
+
+  if(pad)
+    gst_object_unref (pad);
+
+  return ret;
+}
+
+
+static gboolean
+dvb_Gplayer_get_protocol_name(MediaPlayerControl *self, gchar ** prot_name)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gchar * uri = NULL;
+  
+  *prot_name = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  g_object_get (G_OBJECT (pipeline), "uri", &uri, NULL);
+ 
+  if(!uri) {
+    UMMS_DEBUG("Pipe %"GST_PTR_FORMAT" has no uri now!", pipeline);
+    return FALSE;
+  }
+  
+  if(!gst_uri_is_valid(uri)) {
+    UMMS_DEBUG("uri: %s  is invalid", uri);
+    g_free(uri);
+    return FALSE;
+  }
+
+  UMMS_DEBUG("Pipe %"GST_PTR_FORMAT" has no uri is %s", pipeline, uri);
+
+  *prot_name = gst_uri_get_protocol(uri);
+  UMMS_DEBUG("Get the protocol name is %s", *prot_name);
+  
+  g_free(uri);
+  return TRUE;
+}
+
+
+static gboolean
+dvb_Gplayer_get_current_uri(MediaPlayerControl *self, gchar ** uri)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  gchar * s_uri = NULL;
+  
+  *uri = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  pipeline = priv->pipeline;
+  g_object_get (G_OBJECT (pipeline), "uri", &s_uri, NULL);
+ 
+  if(!s_uri) {
+    UMMS_DEBUG("Pipe %"GST_PTR_FORMAT" has no uri now!", pipeline);
+    return FALSE;
+  }
+
+  if(!gst_uri_is_valid(s_uri)) {
+    UMMS_DEBUG("uri: %s  is invalid", s_uri);
+    g_free(s_uri);
+    return FALSE;
+  }
+
+  *uri = s_uri;
+  return TRUE;
+}
+
+static gboolean
+dvb_Gplayer_get_title(MediaPlayerControl *self, gchar ** title)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  *title = g_strdup (priv->title);
+  UMMS_DEBUG ("title = %s", *title);
+
+  return TRUE;
+}
+
+static gboolean
+dvb_player_get_artist(MediaPlayerControl *self, gchar ** artist)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  GstElement *pipeline = NULL;
+  
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+  *artist = g_strdup (priv->artist);
+  UMMS_DEBUG ("artist = %s", *artist);
+  return TRUE;
+}
+
+static gboolean start_recording (MediaPlayerControl *self)
+{
+
+  gboolean ret = FALSE;
+  GstPad *srcpad = NULL;
+  GstPad *sinkpad = NULL;
+  GstElement *filesink = NULL;
+  gchar *location = NULL;
+
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  if ((priv->player_state != PlayerStatePlaying) || priv->tsfilesink || !priv->tsdemux){
+    goto out;
+  }
+
+  if (!(filesink = gst_element_factory_make ("filesink", NULL))) {
+    UMMS_DEBUG ("Creating filesink failed");
+    goto out;
+  }
+  gst_object_ref_sink (filesink);
+
+#define DEFAULT_FILE_LOCATION "/tmp/record.ts"
+  if (priv->file_location)
+    location = priv->file_location;
+  else 
+    location = DEFAULT_FILE_LOCATION;
+  g_object_set (filesink, "location", location, NULL);
+
+  gst_bin_add (GST_BIN(priv->pipeline), filesink);
+
+  if (!(sinkpad = gst_element_get_static_pad (filesink, "sink"))){
+    UMMS_DEBUG ("Getting program pad failed");
+    goto failed;
+  }
+
+  if (!(srcpad = gst_element_get_request_pad (priv->tsdemux, "program"))){
+    UMMS_DEBUG ("Getting program pad failed");
+    goto failed;
+  }
+
+
+  if (GST_PAD_LINK_OK != gst_pad_link (srcpad, sinkpad)) {
+    UMMS_DEBUG ("Linking filesink failed");
+    goto failed;
+  }
+
+  if (GST_STATE_CHANGE_FAILURE == gst_element_set_state (filesink, GST_STATE_PLAYING)) {
+    UMMS_DEBUG ("Setting filesink to playing failed");
+    goto failed;
+  }
+
+
+  ret = TRUE;
+  priv->recording = TRUE;
+  priv->tsfilesink = filesink;
+  priv->request_pad = srcpad;
+
+out:
+    if (sinkpad)
+      gst_object_unref (sinkpad);
+
+    if (!ret) {
+      UMMS_DEBUG ("failed!!!");
+    }
+
+    return ret;
+
+failed:
+    gst_bin_remove (GST_BIN(priv->pipeline), filesink);
+    TEARDOWN_ELEMENT (filesink);
+    goto out;
+}
+
+static gboolean stop_recording (MediaPlayerControl *self) 
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  UMMS_DEBUG ("Begin");
+
+  if (!priv->tsfilesink) {
+    UMMS_DEBUG ("We don't have filesink, can't remove it");
+    return FALSE;
+  }
+
+  gst_bin_remove (GST_BIN(priv->pipeline), priv->tsfilesink);
+  TEARDOWN_ELEMENT (priv->tsfilesink);
+
+  gst_element_release_request_pad (priv->tsdemux, priv->request_pad);
+  gst_object_unref (priv->request_pad);
+  priv->request_pad = NULL;
+
+  priv->recording = FALSE;
+  UMMS_DEBUG ("End");
+  return TRUE;
+}
+
+static gboolean 
+dvb_player_record (MediaPlayerControl *self, gboolean to_record)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+
+  priv = GET_PRIVATE (self);
+
+  if (to_record == priv->recording) {
+    return TRUE;
+  }
+  
+  if (to_record) 
+    return start_recording (self);
+  else 
+    return stop_recording (self);
+}
+
+static gboolean 
+dvb_player_get_pat (MediaPlayerControl *self, GPtrArray **pat)
+{
+  GValueArray *pat_info = NULL;
+  GPtrArray *pat_out = NULL;
+  DvbGPlayerPrivate *priv = NULL;
+  gboolean ret = FALSE;
+  gint i;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+  g_return_val_if_fail (pat, FALSE);
+
+  priv = GET_PRIVATE (self);
+
+  if (!priv->tsdemux)
+    goto out;
+
+  pat_out = g_ptr_array_new ();
+  if (!pat_out) {
+    goto out;
+  }
+
+  g_object_get (priv->tsdemux, "pat-info", &pat_info, NULL);
+
+  if (!pat_info) {
+    UMMS_DEBUG ("no pat-info");
+    goto out;
+  }
+
+
+  for (i = 0; i < pat_info->n_values; i++) {
+    GValue *val = NULL;
+    GObject *entry = NULL;
+    GHashTable *ht = NULL;
+    GValue *val_out = NULL;
+    guint program_num = 0;
+    guint pid = 0;
+
+
+    //get program-number and pid
+    val = g_value_array_get_nth (pat_info, i);
+    entry = g_value_get_object (val);
+    g_object_get (entry, "program-number", &program_num, "pid", &pid, NULL);
+    UMMS_DEBUG ("program-number : %u, pid : %u", program_num, pid);
+
+    //fill the output 
+    ht = g_hash_table_new (NULL, NULL);
+    val_out = g_new0(GValue, 1);
+    g_value_init (val_out, G_TYPE_UINT);
+    g_value_set_uint (val_out, program_num);
+    g_hash_table_insert (ht, "program-number", val_out);
+
+    val_out = g_new0(GValue, 1);
+    g_value_init (val_out, G_TYPE_UINT);
+    g_value_set_uint (val_out, pid);
+    g_hash_table_insert (ht, "pid", val_out);
+
+    g_ptr_array_add (pat_out, ht);
+  }
+  ret = TRUE;
+  *pat = pat_out;
+
+out:
+  if (!ret && pat_out) {
+    g_ptr_array_free (pat_out, FALSE);
+  }
+
+  if (pat_info) 
+    g_value_array_free (pat_info);
+
+  return ret;
+}
+
+/*
+ * pmt() {
+ *    program-number
+ *    pcr-pid
+ *    for (i = 0; i<elementary_stream_number; i++) {
+ *      stream-info() {
+ *        pid
+ *        stream_type
+ *      }
+ *    }
+ * }
+ *
+ */ 
+static gboolean 
+dvb_player_get_pmt (MediaPlayerControl *self, guint *program_num, guint *pcr_pid, GPtrArray **stream_info)
+{
+  DvbGPlayerPrivate *priv;
+  gboolean ret = FALSE;
+  GValue *val = NULL;
+  GHashTable *stream_info_out;
+  gint i;
+
+  GObject *pmt_info;
+  GValueArray *stream_info_array = NULL;
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+  g_return_val_if_fail (program_num, FALSE);
+  g_return_val_if_fail (pcr_pid, FALSE);
+  g_return_val_if_fail (stream_info, FALSE);
+
+  priv = GET_PRIVATE (self);
+
+  if (!priv->tsdemux)
+    goto out;
+
+  g_object_get (priv->tsdemux, "pmt-info", &pmt_info, NULL);
+  if (!pmt_info)
+    goto out;
+
+  //get all the pmt specific info we need
+  g_object_get (pmt_info, "program-number", program_num, "pcr-pid", pcr_pid, "stream-info", &stream_info_array,  NULL);
+  if (!stream_info_array) {
+    UMMS_DEBUG ("getting stream-info failed");
+    goto out;
+  }
+
+  //elementary stream info
+  *stream_info = g_ptr_array_new ();
+  for (i = 0; i < stream_info_array->n_values; i++) {
+    guint pid;
+    guint stream_type;
+    GValue *val_tmp;
+    GObject *stream_info_tmp;
+
+    val_tmp = g_value_array_get_nth (stream_info_array, i);
+    stream_info_tmp = g_value_get_object (val_tmp);
+    g_object_get (stream_info_tmp, "pid", &pid, "stream-type", &stream_type, NULL);
+
+    stream_info_out = g_hash_table_new (NULL, NULL);
+    val_tmp = g_new0 (GValue, 1);
+    g_value_init (val_tmp, G_TYPE_UINT);
+    g_value_set_uint (val_tmp, pid);
+    g_hash_table_insert (stream_info_out, "pid", val_tmp);
+    val_tmp = g_new0 (GValue, 1);
+    g_value_init (val_tmp, G_TYPE_UINT);
+    g_value_set_uint (val_tmp, stream_type);
+    g_hash_table_insert (stream_info_out, "stream-type", val_tmp);
+
+    g_ptr_array_add (*stream_info, stream_info_out);
+  }
+
+  ret =  TRUE;
+
+out: 
+  if (pmt_info)
+    g_object_unref (pmt_info);
+  if (stream_info_array)
+    g_value_array_free (stream_info_array);
+  return ret;
+}
+
+static gboolean 
+dvb_player_get_associated_data_channel (MediaPlayerControl *self, gchar **ip, gint *port)
+{
+  DvbGPlayerPrivate *priv = NULL;
+  
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (IS_MEDIA_PLAYER_CONTROL(self), FALSE);
+  g_return_val_if_fail (ip, FALSE);
+  g_return_val_if_fail (port, FALSE);
+
+  priv = GET_PRIVATE (self);
+
+  //TODO: return the ip and port
+
+  return TRUE;
+}
+
+GstFlowReturn new_Gbuffer_cb (GstAppSink *sink, gpointer user_data)
+{
+  GstBuffer *buf = NULL;
+  GstFlowReturn ret = GST_FLOW_OK;
+
+  buf = gst_app_sink_pull_buffer (sink);
+  if (!buf) {
+    UMMS_DEBUG ("pulling buffer failed");
+    ret = GST_FLOW_ERROR;
+    goto out;
+  }
+
+  //TODO: do something with the buf
+  {
+
+  }
+
+out:
+  if (buf)
+    gst_buffer_unref (buf);
+  return ret;
+}
+
+static gboolean 
+connect_appsink (DvbGPlayer *self)
+{
+  GstElement *appsink;
+  GstPad *srcpad = NULL;
+  GstPad *sinkpad = NULL;
+  gboolean ret = FALSE;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  if (!priv->tsdemux){
+    goto out;
+  }
+
+  if (!(appsink = gst_element_factory_make ("appsink", NULL))) {
+    UMMS_DEBUG ("Creating appsink failed");
+    goto out;
+  }
+
+  GstAppSinkCallbacks *callbacks = g_new0 (GstAppSinkCallbacks, 1);
+  callbacks->new_buffer = new_Gbuffer_cb;
+  gst_app_sink_set_callbacks (GST_APP_SINK_CAST (appsink), callbacks, self, NULL);
+  g_free (callbacks);
+
+  gst_bin_add (GST_BIN(priv->pipeline), appsink);
+
+  if (!(sinkpad = gst_element_get_static_pad (appsink, "sink"))){
+    UMMS_DEBUG ("Getting program pad failed");
+    goto failed;
+  }
+
+  g_object_set (priv->tsdemux, "pids", INIT_PIDS, NULL);
+  if (!(srcpad = gst_element_get_request_pad (priv->tsdemux, "rawts"))){
+    UMMS_DEBUG ("Getting rawts pad failed");
+    goto failed;
+  }
+
+
+  if (GST_PAD_LINK_OK != gst_pad_link (srcpad, sinkpad)) {
+    UMMS_DEBUG ("Linking appsink failed");
+    goto failed;
+  }
+
+  ret = TRUE;
+
+out:
+  if (sinkpad)
+    gst_object_unref (sinkpad);
+  if (srcpad)
+    gst_object_unref (srcpad);
+
+  if (!ret) {
+    UMMS_DEBUG ("failed!!!");
+  }
+
+  return ret;
+
+failed:
+  gst_bin_remove (GST_BIN(priv->pipeline), appsink);
+  goto out;
+}
+
+static void
+media_player_control_init (MediaPlayerControl *iface)
+{
+  MediaPlayerControlClass *klass = (MediaPlayerControlClass *)iface;
+
+  media_player_control_implement_set_uri (klass,
+      dvb_Gplayer_set_uri);
+  media_player_control_implement_set_target (klass,
+      dvb_Gplayer_set_target);
+  media_player_control_implement_play (klass,
+      dvb_Gplayer_play);
+//  media_player_control_implement_pause (klass,
+//      dvb_genral_player_pause);
+  media_player_control_implement_stop (klass,
+      dvb_Gplayer_stop);
+//  media_player_control_implement_set_video_size (klass,
+//      dvb_genral_player_set_video_size);
+//  media_player_control_implement_get_video_size (klass,
+//      dvb_genral_player_get_video_size);
+//  media_player_control_implement_is_seekable (klass,
+//      dvb_genral_player_is_seekable);
+//  media_player_control_implement_set_position (klass,
+//      dvb_genral_player_set_position);
+//  media_player_control_implement_get_position (klass,
+//      dvb_genral_player_get_position);
+//  media_player_control_implement_set_playback_rate (klass,
+//      dvb_genral_player_set_playback_rate);
+//  media_player_control_implement_get_playback_rate (klass,
+//      dvb_genral_player_get_playback_rate);
+//  media_player_control_implement_set_volume (klass,
+//      dvb_genral_player_set_volume);
+//  media_player_control_implement_get_volume (klass,
+//      dvb_genral_player_get_volume);
+//  media_player_control_implement_get_media_size_time (klass,
+//      dvb_genral_player_get_media_size_time);
+//  media_player_control_implement_get_media_size_bytes (klass,
+//      dvb_genral_player_get_media_size_bytes);
+//  media_player_control_implement_has_video (klass,
+//      dvb_genral_player_has_video);
+//  media_player_control_implement_has_audio (klass,
+//      dvb_genral_player_has_audio);
+//  media_player_control_implement_support_fullscreen (klass,
+//      dvb_genral_player_support_fullscreen);
+//  media_player_control_implement_is_streaming (klass,
+//      dvb_genral_player_is_streaming);
+  media_player_control_implement_get_player_state (klass,
+      dvb_player_get_player_state);
+//  media_player_control_implement_get_buffered_bytes (klass,
+//      dvb_genral_player_get_buffered_bytes);
+//  media_player_control_implement_get_buffered_time (klass,
+//      dvb_genral_player_get_buffered_time);
+//  media_player_control_implement_get_current_video (klass,
+//      dvb_genral_player_get_current_video);
+//  media_player_control_implement_get_current_audio (klass,
+//      dvb_genral_player_get_current_audio);
+//  media_player_control_implement_set_current_video (klass,
+//      dvb_genral_player_set_current_video);
+//  media_player_control_implement_set_current_audio (klass,
+//      dvb_genral_player_set_current_audio);
+//  media_player_control_implement_get_video_num (klass,
+//      dvb_genral_player_get_video_num);
+//  media_player_control_implement_get_audio_num (klass,
+//      dvb_genral_player_get_audio_num);
+//  media_player_control_implement_set_proxy (klass,
+//      dvb_genral_player_set_proxy);
+//  media_player_control_implement_set_subtitle_uri (klass,
+//      dvb_genral_player_set_subtitle_uri);
+//  media_player_control_implement_get_subtitle_num (klass,
+//      dvb_genral_player_get_subtitle_num);
+//  media_player_control_implement_set_current_subtitle (klass,
+//      dvb_genral_player_set_current_subtitle);
+//  media_player_control_implement_get_current_subtitle (klass,
+//      dvb_genral_player_get_current_subtitle);
+//  media_player_control_implement_set_buffer_depth (klass,
+//      dvb_genral_player_set_buffer_depth);
+//  media_player_control_implement_set_mute (klass,
+//      dvb_genral_player_set_mute);
+//  media_player_control_implement_is_mute (klass,
+//      dvb_genral_player_is_mute);
+//  media_player_control_implement_suspend (klass,
+//      dvb_genral_player_suspend);
+//  media_player_control_implement_restore (klass,
+//      dvb_genral_player_restore);
+//  media_player_control_implement_set_scale_mode (klass,
+//      dvb_genral_player_set_scale_mode);
+//  media_player_control_implement_get_scale_mode (klass,
+//      dvb_genral_player_get_scale_mode);      
+//  media_player_control_implement_get_video_codec (klass,
+//      dvb_genral_player_get_video_codec);
+//  media_player_control_implement_get_audio_codec (klass,
+//      dvb_genral_player_get_audio_codec);
+//  media_player_control_implement_get_video_bitrate (klass,
+//      dvb_genral_player_get_video_bitrate);
+//  media_player_control_implement_get_audio_bitrate (klass,
+//      dvb_genral_player_get_audio_bitrate);
+//  media_player_control_implement_get_encapsulation (klass,
+//      dvb_genral_player_get_encapsulation);
+//  media_player_control_implement_get_audio_samplerate (klass,
+//      dvb_genral_player_get_audio_samplerate);
+//  media_player_control_implement_get_video_framerate (klass,
+//      dvb_genral_player_get_video_framerate);
+//  media_player_control_implement_get_video_resolution (klass,
+//      dvb_genral_player_get_video_resolution);
+//  media_player_control_implement_get_video_aspect_ratio (klass,
+//      dvb_genral_player_get_video_aspect_ratio);
+//  media_player_control_implement_get_protocol_name (klass,
+//      dvb_genral_player_get_protocol_name);
+//  media_player_control_implement_get_current_uri (klass,
+//      dvb_genral_player_get_current_uri);
+//  media_player_control_implement_get_title (klass,
+//      dvb_genral_player_get_title);
+//  media_player_control_implement_get_artist (klass,
+//      dvb_genral_player_get_artist);
+  media_player_control_implement_record (klass,
+      dvb_player_record);
+  media_player_control_implement_get_pat (klass,
+      dvb_player_get_pat);
+  media_player_control_implement_get_pmt (klass,
+      dvb_player_get_pmt);
+  media_player_control_implement_get_associated_data_channel (klass,
+      dvb_player_get_associated_data_channel);
+}
+
+static void
+dvb_Gplayer_get_property (GObject    *object,
+    guint       property_id,
+    GValue     *value,
+    GParamSpec *pspec)
+{
+  switch (property_id) {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+dvb_Gplayer_set_property (GObject      *object,
+    guint         property_id,
+    const GValue *value,
+    GParamSpec   *pspec)
+{
+  switch (property_id) {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+dvb_Gplayer_dispose (GObject *object)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (object);
+
+  UMMS_DEBUG ("Begin");
+  dvb_Gplayer_stop ((MediaPlayerControl *)object);
+
+  TEARDOWN_ELEMENT(priv->source);
+  TEARDOWN_ELEMENT(priv->tsdemux);
+  TEARDOWN_ELEMENT(priv->vsink);
+  TEARDOWN_ELEMENT(priv->asink);
+  TEARDOWN_ELEMENT(priv->pipeline);
+
+
+  if (priv->target_type == XWindow) {
+    unset_xwindow_target ((MediaPlayerControl *)object);
+  }
+
+  if (priv->disp) {
+    XCloseDisplay (priv->disp);
+    priv->disp = NULL;
+  }
+
+  if(priv->tag_list) 
+    gst_tag_list_free(priv->tag_list);
+  priv->tag_list = NULL;
+
+  G_OBJECT_CLASS (dvb_Gplayer_parent_class)->dispose (object);
+  UMMS_DEBUG ("End");
+}
+
+static void
+dvb_Gplayer_finalize (GObject *object)
+{
+  DvbGPlayerPrivate *priv = GET_PRIVATE (object);
+
+  RESET_STR(priv->uri);
+  RESET_STR(priv->title);
+  RESET_STR(priv->artist);
+
+  G_OBJECT_CLASS (dvb_Gplayer_parent_class)->finalize (object);
+}
+
+static void
+dvb_Gplayer_class_init (DvbGPlayerClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (DvbGPlayerPrivate));
+
+  object_class->get_property = dvb_Gplayer_get_property;
+  object_class->set_property = dvb_Gplayer_set_property;
+  object_class->dispose = dvb_Gplayer_dispose;
+  object_class->finalize = dvb_Gplayer_finalize;
+}
+
+static void
+bus_message_state_change_cb (GstBus     *bus,
+    GstMessage *message,
+    DvbGPlayer  *self)
+{
+
+  GstState old_state, new_state;
+  PlayerState old_player_state;
+  gpointer src;
+  gboolean seekable;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  src = GST_MESSAGE_SRC (message);
+  if (src != priv->pipeline)
+    return;
+
+  gst_message_parse_state_changed (message, &old_state, &new_state, NULL);
+
+  UMMS_DEBUG ("state-changed: old='%s', new='%s'", gst_state[old_state], gst_state[new_state]);
+
+  old_player_state = priv->player_state;
+  if (new_state == GST_STATE_PAUSED) {
+    priv->player_state = PlayerStatePaused;
+  } else if(new_state == GST_STATE_PLAYING) {
+    priv->player_state = PlayerStatePlaying;
+  } else {
+    if (new_state < old_state)//down state change to GST_STATE_READY
+      priv->player_state = PlayerStateStopped;
+  }
+
+  if (priv->pending_state == priv->player_state)
+    priv->pending_state = PlayerStateNull;
+
+  if (priv->player_state != old_player_state) {
+    UMMS_DEBUG ("emit state changed, old=%d, new=%d", old_player_state, priv->player_state);
+    media_player_control_emit_player_state_changed (self, old_player_state, priv->player_state);
+  }
+}
+
+static void
+bus_message_get_tag_cb (GstBus *bus, GstMessage *message, DvbGPlayer  *self)
+{
+  gpointer src;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+  GstPad * src_pad = NULL;
+  GstTagList * tag_list = NULL;
+  guint32 bit_rate;
+  gchar * pad_name = NULL;
+  gchar * element_name = NULL;
+  gchar * title = NULL;
+  gchar * artist = NULL;
+  gboolean metadata_changed = FALSE;
+
+  src = GST_MESSAGE_SRC (message);
+ 
+  if(message->type != GST_MESSAGE_TAG) {
+    UMMS_DEBUG("not a tag message in a registered tag signal, strange");
+    return;
+  }
+
+  gst_message_parse_tag_full (message, &src_pad, &tag_list);
+  if(src_pad) {
+    pad_name = g_strdup (GST_PAD_NAME (src_pad));
+    UMMS_DEBUG("The pad name is %s", pad_name);
+  }
+
+  if(message->src) {
+    element_name = g_strdup (GST_ELEMENT_NAME (message->src));
+    UMMS_DEBUG("The element name is %s", element_name);
+  }
+
+  priv->tag_list = 
+      gst_tag_list_merge(priv->tag_list, tag_list, GST_TAG_MERGE_REPLACE);
+
+  //cache the title
+  if(gst_tag_list_get_string_index (tag_list, GST_TAG_TITLE, 0, &title)) {
+    UMMS_DEBUG("Element: %s, provide the title: %s", element_name, title);
+    RESET_STR(priv->title); 
+    priv->title = title;
+    metadata_changed = TRUE;
+  }
+
+  //cache the artist
+  if(gst_tag_list_get_string_index (tag_list, GST_TAG_ARTIST, 0, &artist)) {
+    UMMS_DEBUG("Element: %s, provide the artist: %s", element_name, artist);
+    RESET_STR(priv->artist); 
+    priv->artist = artist;
+    metadata_changed = TRUE;
+  }
+
+  //only care about artist and title
+  if (metadata_changed) {
+    media_player_control_emit_metadata_changed (self);
+  }
+
+#if 0
+  gint size, i;
+  gchar * video_codec = NULL;
+  gchar * audio_codec = NULL;
+  int out_of_channel = 0;
+  
+  /* This logic may be used when the inputselector is not included. 
+     Now we just get the video and audio codec from inputselector's pad. *
+
+  /* We are now interest in the codec, container format and bit rate. */
+  if(size = gst_tag_list_get_tag_size(tag_list, GST_TAG_VIDEO_CODEC) > 0) {
+    video_codec = g_strdup_printf("%s-->%s Video Codec: ",
+            element_name? element_name: "NULL", pad_name? pad_name: "NULL");
+
+    for (i = 0; i < size; ++i) {
+      gchar *st = NULL;        
+
+      if(gst_tag_list_get_string_index (tag_list, GST_TAG_VIDEO_CODEC, i, &st) && st) {
+        UMMS_DEBUG("Element: %s, Pad: %s provide the video codec named: %s", element_name, pad_name, st);
+        video_codec = g_strconcat(video_codec, st);
+        g_free (st);  
+      }
+    }
+
+    /* store the name for later use. */
+    g_strlcpy(priv->video_codec, video_codec, DVB_PLAYER_MAX_VIDEOCODEC_SIZE);
+    UMMS_DEBUG("%s", video_codec);
+  }
+
+  if(size = gst_tag_list_get_tag_size(tag_list, GST_TAG_AUDIO_CODEC) > 0) {
+    audio_codec = g_strdup_printf("%s-->%s Audio Codec: ",
+            element_name? element_name: "NULL", pad_name? pad_name: "NULL");
+
+    for (i = 0; i < size; ++i) {
+      gchar *st = NULL;        
+
+      if(gst_tag_list_get_string_index (tag_list, GST_TAG_AUDIO_CODEC, i, &st) && st) {
+        UMMS_DEBUG("Element: %s, Pad: %s provide the audio codec named: %s", element_name, pad_name, st);
+        audio_codec = g_strconcat(audio_codec, st);
+        g_free (st);  
+      }
+    }
+
+    UMMS_DEBUG("%s", audio_codec);
+
+    /* need to consider the multi-channel audio case. The demux and decoder
+     * will both send this message. We prefer codec info from decoder now. Need to improve */
+    if(element_name && (g_strstr_len(element_name, strlen(element_name), "demux") ||
+                g_strstr_len(element_name, strlen(element_name), "Demux") ||
+                g_strstr_len(element_name, strlen(element_name), "DEMUX"))) {
+      if(priv->audio_codec_used < DVB_PLAYER_MAX_AUDIO_STREAM) {
+        g_strlcpy(priv->audio_codec[priv->audio_codec_used], audio_codec, DVB_PLAYER_MAX_AUDIOCODEC_SIZE);
+        priv->audio_codec_used++;
+      } else {
+        UMMS_DEBUG("audio_codec need to discard because too many steams");
+        out_of_channel = 1;
+      }
+    } else {
+      UMMS_DEBUG("audio_codec need to discard because it not come from demux");
+    }
+  }
+
+  if(gst_tag_list_get_uint(tag_list, GST_TAG_BITRATE, &bit_rate) && bit_rate > 0) {
+    /* Again, the bitrate info may come from demux and audio decoder, we use demux now. */
+    UMMS_DEBUG("Element: %s, Pad: %s provide the bitrate: %d", element_name, pad_name, bit_rate);
+    if(element_name && (g_strstr_len(element_name, strlen(element_name), "demux") ||
+                g_strstr_len(element_name, strlen(element_name), "Demux") ||
+                g_strstr_len(element_name, strlen(element_name), "DEMUX"))) {
+      gchar * codec = NULL;
+      int have_found = 0;
+
+      /* first we check whether it is the bitrate of video. */
+      if(video_codec) { /* the bitrate sent with the video codec, easy one. */
+        have_found = 1;
+        priv->video_bitrate = bit_rate;
+        UMMS_DEBUG("we set the bitrate: %u for video", bit_rate);
+      }
+
+      if(!have_found) { /* try to compare the element and pad name. */
+        codec = g_strdup_printf("%s-->%s Video Codec: ",
+                element_name? element_name: "NULL", pad_name? pad_name: "NULL");
+        if(g_strncasecmp(priv->video_codec, codec, strlen(codec))) {
+          have_found = 1;
+          priv->video_bitrate = bit_rate;
+          UMMS_DEBUG("we set the bitrate: %u for video", bit_rate);
+        }
+
+        g_free(codec);
+      }
+
+      /* find it in the audio codec stream. */ 
+      if(!have_found) {
+        if(audio_codec) {
+          /* the bitrate sent with the audio codec, easy one. */
+          have_found = 1;
+          if(!out_of_channel) {
+            priv->audio_bitrate[priv->audio_codec_used -1] = bit_rate;
+            UMMS_DEBUG("we set the bitrate: %u for audio stream: %d", bit_rate, priv->audio_codec_used -1);
+          } else {
+            UMMS_DEBUG("audio bitrate need to discard because too many steams");
+          }
+        }
+
+        if(!have_found) {  /* last try, use audio element and pad to index. */
+          codec = g_strdup_printf("%s-->%s Audio Codec: ",
+                  element_name? element_name: "NULL", pad_name? pad_name: "NULL");
+
+          for(i=0; i<priv->audio_codec_used; i++) {
+            if(g_strncasecmp(priv->audio_codec[i], codec, strlen(codec)))
+              break;
+          }
+
+          have_found = 1; /* if not find, we use audio channel as defaule, so always find. */
+          if(i < priv->audio_codec_used) {
+            priv->audio_bitrate[i] = bit_rate;
+            UMMS_DEBUG("we set the bitrate: %u for audio stream: %d", bit_rate, i);
+          } else {
+            UMMS_DEBUG("we can not find the stream for this bitrate: %u, set to the fist stream", bit_rate);
+            priv->audio_bitrate[0] = bit_rate;
+          }
+
+          g_free(codec);
+        }
+      }
+    }
+  }
+
+  if(video_codec)
+    g_free(video_codec);
+  if(audio_codec)
+    g_free(audio_codec);
+#endif
+
+  if(src_pad)
+    g_object_unref(src_pad);
+  gst_tag_list_free (tag_list);
+  if(pad_name)
+    g_free(pad_name);
+  if(element_name)
+    g_free(element_name);
+
+}
+
+static void
+bus_message_eos_cb (GstBus     *bus,
+                    GstMessage *message,
+                    DvbGPlayer  *self)
+{
+  UMMS_DEBUG ("message::eos received on bus");
+  media_player_control_emit_eof (self);
+}
+
+
+static void
+bus_message_error_cb (GstBus     *bus,
+    GstMessage *message,
+    DvbGPlayer  *self)
+{
+  GError *error = NULL;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (self);
+
+  UMMS_DEBUG ("message::error received on bus");
+
+  gst_message_parse_error (message, &error, NULL);
+  _stop_pipe (MEDIA_PLAYER_CONTROL(self));
+
+  media_player_control_emit_error (self, UMMS_ENGINE_ERROR_FAILED, error->message);
+
+  UMMS_DEBUG ("Error emitted with message = %s", error->message);
+
+  g_clear_error (&error);
+}
+
+static GstBusSyncReply
+bus_sync_handler (GstBus *bus,
+                  GstMessage *message,
+                  DvbGPlayer *engine)
+{
+  DvbGPlayerPrivate *priv;
+  GstElement *vsink;
+  GError *err = NULL;
+  GstMessage *msg = NULL;
+
+  if ( GST_MESSAGE_TYPE( message ) != GST_MESSAGE_ELEMENT )
+    return( GST_BUS_PASS );
+
+  if ( ! gst_structure_has_name( message->structure, "prepare-gdl-plane" ) )
+    return( GST_BUS_PASS );
+
+  g_return_val_if_fail (engine, GST_BUS_PASS);
+  g_return_val_if_fail (DVB_IS_GPLAYER (engine), GST_BUS_PASS);
+  priv = GET_PRIVATE (engine);
+
+  vsink =  GST_ELEMENT(GST_MESSAGE_SRC (message));
+  UMMS_DEBUG ("sync-handler received on bus: prepare-gdl-plane, source: %s", GST_ELEMENT_NAME(vsink));
+
+  if (!prepare_plane ((MediaPlayerControl *)engine)) {
+    //Since we are in streame thread, let the vsink to post the error message. Handle it in bus_message_error_cb().
+    err = g_error_new_literal (UMMS_RESOURCE_ERROR, UMMS_RESOURCE_ERROR_NO_RESOURCE, "Plane unavailable");
+    msg = gst_message_new_error (GST_OBJECT_CAST(priv->pipeline), err, "No resource");
+    gst_element_post_message (priv->pipeline, msg);
+    g_error_free (err);
+  }
+
+//  media_player_control_emit_request_window (engine);
+
+  if (message)
+    gst_message_unref (message);
+  return( GST_BUS_DROP );
+}
+
+static void
+video_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data) /* Used as tag change monitor. */
+{
+  DvbGPlayer * priv = (DvbGPlayer *) user_data;
+  media_player_control_emit_video_tag_changed(priv, stream_id);
+}
+
+static void
+audio_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data) /* Used as tag change monitor. */
+{
+  DvbGPlayer * priv = (DvbGPlayer *) user_data;
+  media_player_control_emit_audio_tag_changed(priv, stream_id);
+}
+
+static void
+text_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data) /* Used as tag change monitor. */
+{
+  DvbGPlayer * priv = (DvbGPlayer *) user_data;
+  media_player_control_emit_text_tag_changed(priv, stream_id);
+}
+
+static void
+dvb_Gplayer_init (DvbGPlayer *self)
+{
+  DvbGPlayerPrivate *priv;
+  GstBus *bus;
+  GstElement *pipeline = NULL;
+  GstElement *source = NULL;
+  GstElement *front_queue = NULL;
+  GstElement *tsdemux = NULL;
+  GstElement *vsink = NULL;
+  GstElement *asink = NULL;
+
+  self->priv = PLAYER_PRIVATE (self);
+  priv = self->priv;
+
+  priv->pipeline = pipeline = gst_pipeline_new ("engine-dvb-generic");
+  if (!pipeline) {
+    UMMS_DEBUG ("Creating pipeline elment failed");
+    goto failed;
+  }
+
+  /* we add a message handler */
+  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+  gst_bus_add_signal_watch (bus);
+
+  g_signal_connect_object (bus, "message::error",
+      G_CALLBACK (bus_message_error_cb),
+      self,
+      0);
+
+  g_signal_connect_object (bus, "message::eos",
+      G_CALLBACK (bus_message_eos_cb),
+      self,
+      0);
+
+  g_signal_connect_object (bus,
+      "message::state-changed",
+      G_CALLBACK (bus_message_state_change_cb),
+      self,
+      0);
+
+  g_signal_connect_object (bus,
+      "message::tag",
+      G_CALLBACK (bus_message_get_tag_cb),
+      self,
+      0);
+
+  gst_bus_set_sync_handler(bus, (GstBusSyncHandler) bus_sync_handler,
+      self);
+
+  gst_object_unref (GST_OBJECT (bus));
+
+/*frontend pipeline: dvbsrc --> queue --> ismd_clock_recovery_provider --> flutsdemux*/
+#ifdef DVB_SRC
+  priv->source = source = gst_element_factory_make ("dvbsrc", "dvb-src");
+  if (!source) {
+    UMMS_DEBUG ("Creating dvbsrc failed");
+    goto failed;
+  }
+#else
+  priv->source = source = gst_element_factory_make ("filesrc", NULL);
+  if (!source) {
+    UMMS_DEBUG ("Creating filesrc failed");
+    goto failed;
+  }
+  g_object_set (priv->source, "location", "/home/zhiwen/tvb.ts", NULL); // Qing
+  UMMS_DEBUG ("\n Need to load /home/zhiwen/tvb.ts ");
+
+#endif
+  front_queue   = gst_element_factory_make ("queue", "front-queue");
+  priv->tsdemux = tsdemux = gst_element_factory_make ("flutsdemux", NULL);
+  
+  priv->asink = asink = create_audio_bin();
+  priv->vsink = vsink = create_video_bin();
+
+  if (!front_queue || !tsdemux || !asink || !vsink) {
+    UMMS_DEBUG ("front_queue(%p), tsdemux(%p), asink(%p)", \
+                front_queue, tsdemux, asink, vsink);
+    UMMS_DEBUG ("Creating element failed\n");
+    goto failed;
+  }
+  else{
+    UMMS_DEBUG ("\n OK @ front_queue(%p), tsdemux(%p), asink(%p)", \
+                front_queue, tsdemux, asink, vsink);
+  }
+  //we need ref these element for later using.
+  gst_object_ref_sink (source);
+  gst_object_ref_sink (tsdemux);
+  gst_object_ref_sink (asink);
+  gst_object_ref_sink (vsink);
+
+  g_signal_connect (tsdemux, "pad-added", G_CALLBACK (pad_added_cb), self);
+  g_signal_connect (tsdemux, "no-more-pads", G_CALLBACK (no_more_pads_cb), self);
+
+
+  /* Add and link frontend elements*/
+  gst_bin_add_many (GST_BIN (pipeline),source, front_queue, tsdemux, NULL);
+  gst_element_link_many (source, front_queue, tsdemux, NULL);
+
+  //TODO:Create socket thread
+
+  connect_appsink (self); /// Qing Connection externding pad
+
+  priv->player_state = PlayerStateNull;
+  priv->res_mngr = umms_resource_manager_new ();
+  priv->res_list = NULL;
+  priv->tag_list = NULL;
+
+  priv->seekable = -1;
+  priv->resource_prepared = FALSE;
+  priv->has_video = FALSE;
+  priv->hw_viddec = 0;
+  priv->has_audio = FALSE;
+  priv->hw_auddec = FALSE;
+  priv->title = NULL;
+  priv->artist = NULL;
+
+  //URI is one of metadatas whose change should be notified.
+  media_player_control_emit_metadata_changed (self);
+  return;
+
+failed:
+  TEARDOWN_ELEMENT(pipeline);
+  TEARDOWN_ELEMENT(source);
+  TEARDOWN_ELEMENT(front_queue);
+  TEARDOWN_ELEMENT(tsdemux);
+  TEARDOWN_ELEMENT(vsink);
+  TEARDOWN_ELEMENT(asink);
+  return;
+}
+
+DvbGPlayer *
+engine_dvb_generic_new (void)
+{
+  return g_object_new (DVB_TYPE_GPLAYER, NULL);
+}
+
+#define HW_FORMAT_NUM 4
+#define HW_H264_CAPS \
+             "video/h264, " \
+           "  format = (fourcc) H264, " \
+           "  width = (int) [16,1920], " \
+           "  height = (int) [16,1088]; " \
+           "video/x-h264, " \
+           "  format = (fourcc) X264, " \
+           "  width = (int) [16,1920], " \
+           "  height = (int) [16,1088]; "
+
+
+#define HW_MPEG2_CAPS \
+             "video/mpeg, " \
+           "  format = (fourcc) {MPEG, MP2V}, " \
+           "  width = (int) [16,1920], " \
+           "  height = (int) [16,1088], " \
+           "  mpegversion = (int) [1, 2], " \
+           "  systemstream = (boolean) false, " \
+           "  ispacketized = (boolean) false; "
+
+#define HW_MPEG4_CAPS \
+             "video/mpeg, " \
+           "  mpegversion = (int) 4, " \
+           "  systemstream = (boolean) false; " \
+           "video/x-xvid;" \
+           "video/x-divx, " \
+           "  format = (fourcc) {MPEG, MP4V}, " \
+           "  width = (int) [16,1920], " \
+           "  height = (int) [16,1088], " \
+           "  divxversion = (int) [4, 5] "
+
+#define HW_VC1_CAPS \
+             "video/x-wmv, " \
+           "  wmvversion = (int)3, " \
+           "  format = (fourcc) { WMV3, WVC1 }"
+
+static GstStaticCaps hw_h264_static_caps = GST_STATIC_CAPS (HW_H264_CAPS);
+static GstStaticCaps hw_mpeg2_static_caps = GST_STATIC_CAPS (HW_MPEG2_CAPS);
+static GstStaticCaps hw_mpeg4_static_caps = GST_STATIC_CAPS (HW_MPEG4_CAPS);
+static GstStaticCaps hw_vc1_static_caps = GST_STATIC_CAPS (HW_VC1_CAPS);
+
+static GstStaticCaps *hw_static_caps[HW_FORMAT_NUM] = {&hw_h264_static_caps, 
+                                        &hw_mpeg2_static_caps, 
+                                        &hw_mpeg4_static_caps, 
+                                        &hw_vc1_static_caps};
+
+static void
+pad_added_cb (GstElement *element,
+		GstPad     *pad,
+		gpointer    data)
+{
+  GstPad *decoded_pad = NULL;
+  GstPad *sinkpad = NULL;
+  GstPad *srcpad  = NULL;
+  DvbGPlayer *player = (DvbGPlayer *) data;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (player);
+  gchar *name = gst_pad_get_name (pad);
+
+  UMMS_DEBUG ("flutsdemux pad: %s added", name);
+  if (!g_strcmp0 (name, "rawts")) {
+    g_print ("pad(%s) added\n", GST_PAD_NAME(pad));
+  } else if (!g_strcmp0 (name, "program")) {
+    g_print ("pad(%s) added\n", GST_PAD_NAME(pad));
+  }else {
+    UMMS_DEBUG ("autoplug elementary stream pad: %s", name);
+    if (!priv->mq) {
+      priv->mq = gst_element_factory_make ("multiqueue", NULL);
+      if (!priv->mq) {
+        UMMS_DEBUG ("Making multiqueue failed");
+        goto out;
+      }
+      gst_bin_add (GST_BIN (priv->pipeline), priv->mq);
+      gst_element_set_state (priv->mq, GST_STATE_PAUSED);
+    }
+
+    if (!(srcpad = link_multiqueue (player, pad))) {
+      UMMS_DEBUG ("Linking multiqueue failed");
+      goto out;
+    }
+
+    if (g_str_has_prefix (name, "video")) {
+      autoplug_pad (player, srcpad, CHAIN_TYPE_VIDEO);
+    } else if (g_str_has_prefix (name, "audio")) {
+      autoplug_pad (player, srcpad, CHAIN_TYPE_AUDIO);
+      //link_sink (player, srcpad);
+    } else {
+      //FIXME: do we need to handle flustsdemux's subpicture/private pad? 
+    }
+  }
+
+out:
+  if (srcpad)
+    gst_object_unref (srcpad);
+  if (sinkpad)
+    gst_object_unref (sinkpad);
+  if (name)
+    g_free (name);
+}
+
+static void
+no_more_pads_cb (GstElement *element, gpointer data)
+{
+  DvbGPlayer *player = (DvbGPlayer *)data;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (player);
+  GstStateChangeReturn ret;
+
+  /*set pipeline to playing, so that sinks start to render data*/
+  UMMS_DEBUG ("Set pipe to playing");
+  if ((ret = gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)) == GST_STATE_CHANGE_FAILURE) {
+    UMMS_DEBUG ("Settint pipeline to playing failed");
+  }
+  return;
+}
+
+/* 
+ * autoplug the pad with a decoder and proceed to link a sink
+ */
+static gboolean autoplug_pad(DvbGPlayer *player, GstPad *pad, gint chain_type)
+{
+  GstCaps *caps = NULL;
+  gboolean ret = TRUE;
+  GList *compatible_elements = NULL;
+  GList *walk = NULL;
+  GList *chain_elements = NULL;//store the elements autoplugged from this pad.
+  gboolean done = FALSE;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (player);
+
+  UMMS_DEBUG ("autoplugging pad: %s, caps: ", GST_PAD_NAME (pad));
+  caps = gst_pad_get_caps (pad);
+
+  if (!caps || gst_caps_is_empty (caps)){
+    UMMS_DEBUG ("Unknow caps");
+    ret = FALSE;
+    goto out;
+  }
+
+  if (!gst_caps_is_fixed (caps)) {
+    UMMS_DEBUG ("caps is not fixed, strange");
+    goto out;
+  }
+
+  update_elements_list (player);
+
+  compatible_elements =
+      gst_element_factory_list_filter (priv->elements, caps, GST_PAD_SINK,
+      FALSE);
+  if (!compatible_elements) {
+    UMMS_DEBUG ("no compatible element available for this pad:%s, caps : %"GST_PTR_FORMAT, GST_PAD_NAME(pad), caps);
+    ret = FALSE;
+    goto out;
+  }
+  
+  gst_plugin_feature_list_debug (compatible_elements);
+
+  //make and connect element
+  for (walk = compatible_elements; walk; walk= walk->next) {
+    GstElementFactory *factory;
+    GstElement *element;
+    GstPad *sinkpad;
+    const gchar *klass;
+    gboolean link_ret;
+
+    factory = GST_ELEMENT_FACTORY_CAST (walk->data);
+
+    /* 
+     * if it's a sink, we treat this pad as decoded pad,
+     * and try to connnect this pad with our custom sink other than the auto-detected one
+     */
+    if (gst_element_factory_list_is_type (factory, GST_ELEMENT_FACTORY_TYPE_SINK)) {
+      UMMS_DEBUG ("we found a \"decoded\" pad");
+
+      klass = gst_element_factory_get_klass (factory);
+
+      if (strstr (klass, "Audio") || strstr (klass, "Video")) {
+        UMMS_DEBUG ("linking custom sink");
+        link_ret = link_sink (player, pad);
+      } else {
+        /* unknown klass, skip this element */
+        UMMS_DEBUG ("unknown sink klass %s found", klass);
+        continue;
+      }
+
+      done = link_ret;
+      break;
+    }
+
+    /*it is not sink, autoplug the dec element*/
+    if ((element = gst_element_factory_create (factory, NULL)) == NULL) {
+      UMMS_DEBUG ("Could not create an element from %s",
+          gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
+      continue;
+    }
+
+    if ((gst_element_set_state (element,
+                GST_STATE_READY)) == GST_STATE_CHANGE_FAILURE) {
+      UMMS_DEBUG ("Couldn't set %s to READY",
+          GST_ELEMENT_NAME (element));
+      gst_object_unref (element);
+      continue;
+    }
+
+    if (!(sinkpad = get_sink_pad (element))) {
+      UMMS_DEBUG ("Element %s doesn't have a sink pad",
+          GST_ELEMENT_NAME (element));
+      gst_element_set_state (element, GST_STATE_NULL);
+      gst_object_unref (element);
+      continue;
+    }
+
+    if (!(gst_bin_add (GST_BIN (priv->pipeline), element))) {
+      UMMS_DEBUG ("Couldn't add %s to the bin",
+          GST_ELEMENT_NAME (element));
+      gst_object_unref (sinkpad);
+      gst_element_set_state (element, GST_STATE_NULL);
+      gst_object_unref (element);
+      continue;
+    }
+
+    if ((gst_pad_link (pad, sinkpad)) != GST_PAD_LINK_OK) {
+      UMMS_DEBUG ("Link failed on pad %s:%s",
+          GST_DEBUG_PAD_NAME (sinkpad));
+      gst_element_set_state (element, GST_STATE_NULL);
+      gst_object_unref (sinkpad);
+      gst_bin_remove (GST_BIN (priv->pipeline), element);
+      continue;
+    }
+    gst_object_unref (sinkpad);
+    UMMS_DEBUG ("linked on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
+
+    if (!autoplug_dec_element (player, element)) {
+      gst_bin_remove (GST_BIN (priv->pipeline), element);
+      continue;
+    }
+
+    /* Bring the element to the state of the parent */
+    if ((gst_element_set_state (element,
+                GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) {
+
+      UMMS_DEBUG ("Couldn't set %s to PAUSED",
+          GST_ELEMENT_NAME (element));
+
+      /* Remove this element and the downstream one we just added.*/
+      gst_element_set_state (element, GST_STATE_NULL);
+      gst_bin_remove (GST_BIN (priv->pipeline), element);
+      continue;
+    }
+
+    /*successful*/
+    done = TRUE;
+    break;
+  }
+
+  ret = done;
+
+out:
+  if (caps)
+    gst_caps_unref (caps);
+
+  if (compatible_elements)
+    gst_plugin_feature_list_free (compatible_elements);
+  return ret;
+}
+
+/*
+ * link the pad to multiqueue and return corresponding src pad.
+ * unref the returned pad after usage. 
+ */
+static GstPad *link_multiqueue (DvbGPlayer *player, GstPad *pad)
+{
+  GstPad *srcpad = NULL;
+  GstPad *sinkpad = NULL;
+  GstIterator *it = NULL;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (player);
+
+  if (!priv->mq) {
+    UMMS_DEBUG ("No multiqueue");
+    return NULL;
+  }
+
+  if (!(sinkpad = gst_element_get_request_pad (priv->mq, "sink%d"))) {
+    UMMS_DEBUG ("Couldn't get sinkpad from multiqueue");
+    return NULL;
+  }
+
+  if ((gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK)) {
+    UMMS_DEBUG ("Couldn't link demuxer and multiqueue");
+    goto error;
+  }
+
+  it = gst_pad_iterate_internal_links (sinkpad);
+
+  if (!it || (gst_iterator_next (it, (gpointer) & srcpad)) != GST_ITERATOR_OK
+      || srcpad == NULL) {
+    UMMS_DEBUG ("Couldn't get corresponding srcpad from multiqueue for sinkpad %" GST_PTR_FORMAT,
+        sinkpad);
+    goto error;
+  }
+
+out:
+  if (sinkpad)
+    gst_object_unref (sinkpad);
+
+  if (it)
+    gst_iterator_free (it);
+
+  return srcpad;
+
+error:
+  gst_element_release_request_pad (priv->mq, sinkpad);
+  goto out;
+}
+
+//decodable and sink elements
+static void
+update_elements_list (DvbGPlayer *player)
+{
+  GList *res, *sinks;
+  DvbGPlayerPrivate *priv = GET_PRIVATE (player);
+
+  if (!priv->elements ||
+      priv->elements_cookie !=
+      gst_default_registry_get_feature_list_cookie ()) {
+    if (priv->elements)
+      gst_plugin_feature_list_free (priv->elements);
+    res =
+        gst_element_factory_list_get_elements
+        (GST_ELEMENT_FACTORY_TYPE_DECODABLE, GST_RANK_MARGINAL);
+    sinks =
+        gst_element_factory_list_get_elements
+        (GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS, GST_RANK_MARGINAL);
+    priv->elements = g_list_concat (res, sinks);
+    priv->elements =
+        g_list_sort (priv->elements, gst_plugin_feature_rank_compare_func);
+    priv->elements_cookie = gst_default_registry_get_feature_list_cookie ();
+  }
+}
+
+static GstPad *
+get_sink_pad (GstElement * element)
+{
+  GstIterator *it;
+  GstPad *pad = NULL;
+  gpointer point;
+
+  it = gst_element_iterate_sink_pads (element);
+
+  if ((gst_iterator_next (it, &point)) == GST_ITERATOR_OK)
+    pad = (GstPad *) point;
+
+  gst_iterator_free (it);
+
+  return pad;
+}
+
+static gboolean
+autoplug_dec_element (DvbGPlayer *player, GstElement * element)
+{
+  GList *pads;
+  gboolean ret;
+
+  UMMS_DEBUG ("Attempting to connect element %s further",
+      GST_ELEMENT_NAME (element));
+
+  for (pads = GST_ELEMENT_GET_CLASS (element)->padtemplates; pads;
+      pads = g_list_next (pads)) {
+    GstPadTemplate *templ = GST_PAD_TEMPLATE (pads->data);
+    const gchar *templ_name;
+
+    /* we are only interested in source pads */
+    if (GST_PAD_TEMPLATE_DIRECTION (templ) != GST_PAD_SRC)
+      continue;
+
+    templ_name = GST_PAD_TEMPLATE_NAME_TEMPLATE (templ);
+    UMMS_DEBUG ("got a source pad template %s", templ_name);
+
+    /* We only care about always pad */
+    switch (GST_PAD_TEMPLATE_PRESENCE (templ)) {
+      case GST_PAD_ALWAYS:
+      {
+        /* get the pad that we need to autoplug */
+        GstPad *pad = gst_element_get_static_pad (element, templ_name);
+        if (!pad) {
+          /* strange, pad is marked as always but it's not
+           * there. Fix the element */
+          UMMS_DEBUG ("could not get the pad for always template %s", templ_name);
+          break;
+        }
+
+        UMMS_DEBUG ("got the pad for always template %s",
+            templ_name);
+        /* 
+         * here is the pad, we need link it to sink. 
+         * note that we just autoplug the first found always pad unless autoplugging failed.
+         */
+        ret = link_sink (player, pad);
+        gst_object_unref (pad);
+
+        if (ret) {
+          return TRUE;
+        }
+        break;
+      }
+      case GST_PAD_SOMETIMES:
+      case GST_PAD_REQUEST:
+      {
+        UMMS_DEBUG ("ignoring sometimes and request padtemplate %s", templ_name);
+        break;
+      }
+    }
+  }
+
+  return FALSE;
+}
+
+static gboolean link_sink (DvbGPlayer *player, GstPad *pad)
+{
+  DvbGPlayerPrivate *priv; 
+  GstStructure *s;
+  const gchar *name;
+  GstPad *sinkpad = NULL;
+  GstCaps *caps   = NULL;
+  gboolean ret = TRUE;
+
+  g_return_val_if_fail (DVB_IS_GPLAYER (player), FALSE);
+  g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
+
+  priv = GET_PRIVATE (player);
+
+  caps = gst_pad_get_caps_reffed (pad);
+  UMMS_DEBUG ("pad:%s, caps : %"GST_PTR_FORMAT, GST_PAD_NAME(pad), caps);
+
+  s = gst_caps_get_structure (caps, 0);
+
+  if (s) {
+    GstElement *sink = NULL;
+    GstElement *queue = NULL;
+    name = gst_structure_get_name (s);
+    g_printf ("caps name : %s\n", name);
+
+    if (g_str_has_prefix (name, "video")) {
+      sink = priv->vsink;
+      g_print ("Found video decoded pad: %p, linking it\n", pad);
+
+    } else if(g_str_has_prefix (name, "audio")) {
+      g_print ("Found audio decoded pad: %p, linking it\n", pad);
+      sink = priv->asink;
+
+    } else {
+      g_print ("Ignore this pad\n");
+    }
+
+    if (sink) {
+      if (!(queue = gst_element_factory_make ("queue", NULL))) {
+        UMMS_DEBUG ("Creating queue failed");
+        goto out;
+      }
+
+      gst_bin_add (GST_BIN (priv->pipeline), queue);
+      gst_bin_add (GST_BIN (priv->pipeline), sink);
+      if (!gst_element_link (queue, sink)) {
+        UMMS_DEBUG ("linking queue and sink failed");
+        gst_element_set_state (queue, GST_STATE_NULL);
+        gst_bin_remove (GST_BIN (priv->pipeline), queue);
+        gst_element_set_state (sink, GST_STATE_NULL);
+        gst_bin_remove (GST_BIN (priv->pipeline), sink);
+        ret = FALSE;
+        goto out;
+      }
+
+      sinkpad = gst_element_get_static_pad (queue, "sink");
+      if (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK) {
+        g_print ("link pad(%s): sinkpad(%s) failed\n", GST_PAD_NAME(pad), GST_PAD_NAME (sinkpad));
+        gst_element_set_state (queue, GST_STATE_NULL);
+        gst_bin_remove (GST_BIN (priv->pipeline), queue);
+        gst_element_set_state (sink, GST_STATE_NULL);
+        gst_bin_remove (GST_BIN (priv->pipeline), sink);
+        ret = FALSE;
+        goto out;
+      }
+
+      gst_element_set_state (queue, GST_STATE_PAUSED);
+      gst_element_set_state (sink, GST_STATE_PAUSED);
+      g_print ("pad: %p linked\n", pad);
+    } 
+  } else {
+    g_print ("Getting caps structure failed\n");
+    ret = FALSE;
+    goto out;
+  }
+ 
+out:
+
+  if (caps)
+    gst_caps_unref (caps);
+
+  if (sinkpad)
+    gst_object_unref (sinkpad);
+
+  return ret;
+}
+
+GstElement *
+create_video_bin (void)
+{
+  GstElement *video_convert = NULL;
+  GstElement *video_scale = NULL;
+  GstElement *video_sink = NULL;
+  GstElement *video_bin = NULL;
+  GstPad *sinkpad = NULL;
+
+  video_convert = gst_element_factory_make ("ffmpegcolorspace", NULL);
+  video_scale = gst_element_factory_make ("videoscale", NULL);
+  video_sink = gst_element_factory_make ("autovideosink", NULL);
+  video_bin = gst_bin_new ("video-bin");
+
+  if (!video_convert || !video_scale || !video_sink || !video_bin) {
+    UMMS_DEBUG ("Creating video elements failed, \
+        video_convert(%p), video_scale(%p), video_sink(%p), video_bin(%p)",
+        video_convert, video_scale, video_sink, video_bin);
+    goto make_failed;
+  }
+
+  gst_bin_add_many (GST_BIN (video_bin), video_convert, video_scale, video_sink, NULL);
+  if (!gst_element_link_many (video_convert, video_scale, video_sink, NULL)) {
+    UMMS_DEBUG ("linking video elements failed");
+    goto link_failed;
+  }
+
+  sinkpad = gst_element_get_static_pad (video_convert, "sink");
+  gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", sinkpad));
+  gst_object_unref (GST_OBJECT (sinkpad));
+
+  return video_bin;
+
+make_failed:
+  if (video_convert)
+    gst_object_unref (video_convert);
+  if (video_scale)
+    gst_object_unref (video_scale);
+  if (video_sink)
+    gst_object_unref (video_sink);
+
+link_failed:
+  if (video_bin)
+    gst_object_unref (video_bin);
+  return NULL;
+}
+
+GstElement *
+create_audio_bin (void)
+{
+  GstElement *audio_convert = NULL;
+  GstElement *audio_resample = NULL;
+  GstElement *audio_sink = NULL;
+  GstElement *audio_bin = NULL;
+  GstPad *sinkpad = NULL;
+
+  audio_convert = gst_element_factory_make ("audioconvert", NULL);
+  audio_resample = gst_element_factory_make ("audioresample", NULL);
+  audio_sink = gst_element_factory_make ("autoaudiosink", NULL);
+  audio_bin = gst_bin_new ("audio-bin");
+
+  if (!audio_convert || !audio_resample || !audio_sink || !audio_bin) {
+    UMMS_DEBUG ("Creating audio elements failed, \
+        audio_convert(%p), audio_resample(%p), audio_sink(%p), audio_bin(%p)",
+        audio_convert, audio_resample, audio_sink, audio_bin);
+    goto make_failed;
+  }
+
+  gst_bin_add_many (GST_BIN (audio_bin), audio_convert, audio_resample, audio_sink, NULL);
+  if (!gst_element_link_many (audio_convert, audio_resample, audio_sink, NULL)) {
+    UMMS_DEBUG ("linking audio elements failed");
+    goto link_failed;
+  }
+
+  sinkpad = gst_element_get_static_pad (audio_convert, "sink");
+  gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", sinkpad));
+  gst_object_unref (GST_OBJECT (sinkpad));
+
+  return audio_bin;
+
+make_failed:
+  if (audio_convert)
+    gst_object_unref (audio_convert);
+  if (audio_resample)
+    gst_object_unref (audio_resample);
+  if (audio_sink)
+    gst_object_unref (audio_sink);
+
+link_failed:
+  if (audio_bin)
+    gst_object_unref (audio_bin);
+  return NULL;
+}
--- src/engine-dvb-generic.h
+++ src/engine-dvb-generic.h
+#ifndef _ENGINE_DVB_GENERIC_H
+#define _ENGINE_DVB_GENERIC_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define DVB_TYPE_GPLAYER dvb_Gplayer_get_type()
+
+#define DVB_GPLAYER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  DVB_TYPE_GPLAYER, DvbGPlayer))
+
+#define DVB_GPLAYER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  DVB_TYPE_GPLAYER, DvbGPlayerClass))
+
+#define DVB_IS_GPLAYER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  DVB_TYPE_GPLAYER))
+
+#define DVB_IS_GPLAYER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  DVB_TYPE_GPLAYER))
+
+#define DVB_GPLAYER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  DVB_TYPE_GPLAYER, DvbGPlayerClass))
+
+typedef struct _DvbGPlayer DvbGPlayer;
+typedef struct _DvbGPlayerClass DvbGPlayerClass;
+typedef struct _DvbGPlayerPrivate DvbGPlayerPrivate;
+
+struct _DvbGPlayer
+{
+  GObject parent;
+
+  DvbGPlayerPrivate *priv;
+};
+
+
+struct _DvbGPlayerClass
+{
+  GObjectClass parent_class;
+
+};
+
+
+GType dvb_Gplayer_get_type (void) G_GNUC_CONST;
+
+DvbGPlayer *engine_dvb_generic_new (void);
+
+G_END_DECLS
+
+#endif /* _ENGINE_DVB_GENERIC_H */
--- src/engine-gst.c
+++ src/engine-gst.c
@@ -153,6 +153,19 @@
   GstTagList *tag_list;
   gchar *title;
   gchar *artist;
+
+  /*audio/video tag stuff*/
+  //stream number
+  gint video_stream_id;
+  gint audio_stream_id;
+
+  //idle source id
+  guint video_tags_change_id;
+  guint audio_tags_change_id;
+
+  //locks for idle source
+  GMutex *video_tags_change_lock;
+  GMutex *audio_tags_change_lock;
 };
 
 static gboolean _query_buffering_percent (GstElement *pipe, gdouble *percent);
@@ -406,6 +419,7 @@
     g_object_set (vsink, "gdl-plane", plane, NULL);
 
   if (new_vsink) {
+    g_object_set (new_vsink, "qos", FALSE, NULL);
     g_object_set (priv->pipeline, "video-sink", vsink, NULL);
     UMMS_DEBUG ("Set ismd_vidrend_bin to playbin2");
   }
@@ -1008,6 +1022,22 @@
   return TRUE;
 }
 
+static gboolean 
+validate_rect (uint x, uint y, uint w, uint h)
+{
+  //constraints due to ismd_vidpporc
+  if (w < 48 || h < 48) {
+    UMMS_DEBUG ("Invalid width(%u) or height(%u)", w, h);
+    return FALSE;
+  }
+
+  if (x > 1920 || y > 1080) {
+    UMMS_DEBUG ("Invalid x(%u) or y(%u)", x, y);
+    return FALSE;
+  }
+  return TRUE;
+}
+
 static gboolean
 engine_gst_set_video_size (MediaPlayerControl *self,
     guint x, guint y, guint w, guint h)
@@ -1019,7 +1049,9 @@
   GstElement *tsink_bin = NULL;
 
   g_return_val_if_fail (pipe, FALSE);
-  UMMS_DEBUG ("invoked");
+
+  if (!validate_rect (x, y, w, h))
+    goto OUT;
 
   //We use ismd_vidrend_bin as video-sink, so we can set rectangle property.
   g_object_get (G_OBJECT(pipe), "video-sink", &vsink_bin, NULL);
@@ -1974,6 +2006,7 @@
   pipe = priv->pipeline;
   g_return_val_if_fail (GST_IS_ELEMENT (pipe), FALSE);
 
+  UMMS_DEBUG("Want to set the scale mode to %d", scale_mode);
   /* We assume that the video-sink is just ismd_vidrend_bin, because if not
      the scale mode is not supported yet in gst sink bins. */
   g_object_get (G_OBJECT(pipe), "video-sink", &vsink_bin, NULL);
@@ -2072,22 +2105,25 @@
       goto OUT;
     }
 
+    UMMS_DEBUG("scale_mode value number is %d", g_value_get_enum(&val));
     eval = g_enum_get_value (eclass, g_value_get_enum(&val));
     if (eval == NULL) {
       ret = FALSE;
       goto OUT;
     }
 
-    if (strcmp(eval->value_nick, "none")) {
+    UMMS_DEBUG("value_nick is %s", eval->value_nick);
+
+    if (!strcmp(eval->value_nick, "none")) {
       *scale_mode = ScaleModeNoScale;
       goto OUT;
-    } else if (strcmp(eval->value_nick, "scale2fit")) {
+    } else if (!strcmp(eval->value_nick, "scale2fit")) {
       *scale_mode = ScaleModeFill;
       goto OUT;
-    } else if (strcmp(eval->value_nick, "zoom2fit")) {
+    } else if (!strcmp(eval->value_nick, "zoom2fit")) {
       *scale_mode = ScaleModeKeepAspectRatio;
       goto OUT;
-    } else if (strcmp(eval->value_nick, "zoom2fill")) {
+    } else if (!strcmp(eval->value_nick, "zoom2fill")) {
       *scale_mode = ScaleModeFillKeepAspectRatio;
       goto OUT;
     } else {
@@ -2861,6 +2897,22 @@
     gst_tag_list_free(priv->tag_list);
   priv->tag_list = NULL;
 
+  if (priv->video_tags_change_id) {
+    g_source_remove (priv->video_tags_change_id);
+  }
+
+  if (priv->audio_tags_change_id) {
+    g_source_remove (priv->audio_tags_change_id);
+  }
+
+  if (priv->video_tags_change_lock) {
+    g_mutex_free (priv->video_tags_change_lock);
+  }
+
+  if (priv->audio_tags_change_lock) {
+    g_mutex_free (priv->audio_tags_change_lock);
+  }
+
   G_OBJECT_CLASS (engine_gst_parent_class)->dispose (object);
 }
 
@@ -2949,6 +3001,7 @@
   EngineGstPrivate *priv = GET_PRIVATE (self);
   GstPad * src_pad = NULL;
   GstTagList * tag_list = NULL;
+  GstTagList * result_list = NULL;
   gchar * pad_name = NULL;
   gchar * element_name = NULL;
   gchar * title = NULL;
@@ -2996,9 +3049,13 @@
   }
 
   //tag_list will be freed in gst_tag_list_merge(), so we don't need to free it by ourself
-  priv->tag_list =
+  result_list =
     gst_tag_list_merge(priv->tag_list, tag_list, GST_TAG_MERGE_REPLACE);
 
+  if (priv->tag_list)
+    gst_tag_list_free (priv->tag_list);
+  priv->tag_list = result_list;
+
 #if 0
   gint size, i;
   gchar * video_codec = NULL;
@@ -3254,25 +3311,78 @@
   return( GST_BUS_DROP );
 }
 
+
+
+static gboolean video_tags_changed_nofity (EngineGst *player)                                
+{                                                                               
+  EngineGstPrivate *priv = GET_PRIVATE (player);                                
+  //UMMS_DEBUG ("Begin");
+  g_mutex_lock (priv->video_tags_change_lock);                               
+  media_player_control_emit_video_tag_changed(player, priv->video_stream_id);
+  priv->video_tags_change_id = 0;                                            
+  g_mutex_unlock (priv->video_tags_change_lock);                             
+  //UMMS_DEBUG ("End");
+  return FALSE;                                                                 
+};
+
+static gboolean audio_tags_changed_nofity (EngineGst *player)                 
+{                                                                               
+  EngineGstPrivate *priv = GET_PRIVATE (player);                                
+  //UMMS_DEBUG ("Begin");
+  g_mutex_lock (priv->audio_tags_change_lock);                               
+  media_player_control_emit_audio_tag_changed(player, priv->audio_stream_id);
+  priv->audio_tags_change_id = 0;                                            
+  g_mutex_unlock (priv->audio_tags_change_lock);                             
+  //UMMS_DEBUG ("End");
+  return FALSE;                                                                 
+};
+
 static void
 video_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data) /* Used as tag change monitor. */
 {
-  EngineGst * priv = (EngineGst *) user_data;
-  media_player_control_emit_video_tag_changed(priv, stream_id);
+  EngineGst * player = (EngineGst *) user_data;
+  EngineGstPrivate *priv = GET_PRIVATE (player);
+  gint cur_stream_id = 0;
+
+  UMMS_DEBUG ("Begin");
+  g_object_get (G_OBJECT (playbin2), "current-video", &cur_stream_id, NULL);
+
+  /* Only get the updated tags if it's for our current stream id */
+  if (cur_stream_id != stream_id)
+    return;
+
+  g_mutex_lock (priv->video_tags_change_lock);
+  priv->video_stream_id = stream_id;
+  if (priv->video_tags_change_id) {
+    g_source_remove (priv->video_tags_change_id);
+  }
+  priv->video_tags_change_id = g_idle_add ((GSourceFunc) video_tags_changed_nofity, player);
+  g_mutex_unlock (priv->video_tags_change_lock);
+  UMMS_DEBUG ("End");
 }
 
 static void
 audio_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data) /* Used as tag change monitor. */
 {
-  EngineGst * priv = (EngineGst *) user_data;
-  media_player_control_emit_audio_tag_changed(priv, stream_id);
-}
+  EngineGst * player = (EngineGst *) user_data;
+  EngineGstPrivate *priv = GET_PRIVATE (player);
+  gint cur_stream_id = 0;
 
-static void
-text_tags_changed_cb (GstElement *playbin2, gint stream_id, gpointer user_data) /* Used as tag change monitor. */
-{
-  EngineGst * priv = (EngineGst *) user_data;
-  media_player_control_emit_text_tag_changed(priv, stream_id);
+  UMMS_DEBUG ("Begin");
+  g_object_get (G_OBJECT (playbin2), "current-audio", &cur_stream_id, NULL);
+
+  /* Only get the updated tags if it's for our current stream id */
+  if (cur_stream_id != stream_id)
+    return;
+
+  g_mutex_lock (priv->audio_tags_change_lock);
+  priv->audio_stream_id = stream_id;
+  if (priv->audio_tags_change_id) {
+    g_source_remove (priv->audio_tags_change_id);
+  }
+  priv->audio_tags_change_id = g_idle_add ((GSourceFunc) audio_tags_changed_nofity, player);
+  g_mutex_unlock (priv->audio_tags_change_lock);
+  UMMS_DEBUG ("End");
 }
 
 /* GstPlayFlags flags from playbin2 */
@@ -3346,9 +3456,6 @@
   g_signal_connect (priv->pipeline,
                     "audio-tags-changed", G_CALLBACK (audio_tags_changed_cb), self);
 
-  g_signal_connect (priv->pipeline,
-                    "text-tags-changed", G_CALLBACK (text_tags_changed_cb), self);
-
   /*
    *Use GST_PLAY_FLAG_DOWNLOAD flag to enable Gstreamer Download buffer mode,
    *so that we can query the buffered time/bytes, and further the time rangs.
@@ -3366,6 +3473,15 @@
 
   priv->tag_list = NULL;
 
+  priv->video_stream_id = 0;
+  priv->video_tags_change_id = 0;
+  priv->video_tags_change_lock = g_mutex_new ();
+
+  priv->audio_stream_id = 0;
+  priv->audio_tags_change_id = 0;
+  priv->audio_tags_change_lock = g_mutex_new ();
+  
+
   //Setup default target.
 #define FULL_SCREEN_RECT "0,0,0,0"
   setup_ismd_vbin (MEDIA_PLAYER_CONTROL(self), FULL_SCREEN_RECT, UPP_A);
--- src/media-player-factory.c
+++ src/media-player-factory.c
@@ -27,6 +27,7 @@
 #include "media-player-control.h"
 #include "engine-gst.h"
 #include "engine-generic.h"
+#include "engine-dvb-generic.h"
 #include "dvb-player.h"
 
 
@@ -85,8 +86,8 @@
 /*01: CETV-Normal*/ engine_gst_new,
 /*02: CETV-DVB*/dvb_player_new,
 /*10: */NULL,
-/*11: Netbook->Normal*/engine_generic_new,
-/*12: Netbook->DVB*/engine_fake_new
+/*11: Netbook->Normal*/ engine_generic_new,
+/*12: Netbook->DVB*/ engine_dvb_generic_new
 };
 
 MediaPlayerControl *
--- src/meego-media-player-control.c
+++ src/meego-media-player-control.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <dbus/dbus-glib.h>
-#include "umms-marshals.h"
-#include "meego-media-player-control.h"
-
-struct _MeegoMediaPlayerControlClass {
-  GTypeInterface parent_class;
-  meego_media_player_control_set_uri_impl set_uri;
-  meego_media_player_control_set_target_impl set_target;
-  meego_media_player_control_play_impl play;
-  meego_media_player_control_pause_impl pause;
-  meego_media_player_control_stop_impl stop;
-  meego_media_player_control_set_position_impl set_position;
-  meego_media_player_control_get_position_impl get_position;
-  meego_media_player_control_set_playback_rate_impl set_playback_rate;
-  meego_media_player_control_get_playback_rate_impl get_playback_rate;
-  meego_media_player_control_set_volume_impl set_volume;
-  meego_media_player_control_get_volume_impl get_volume;
-  meego_media_player_control_set_window_id_impl set_window_id;
-  meego_media_player_control_set_video_size_impl set_video_size;
-  meego_media_player_control_get_video_size_impl get_video_size;
-  meego_media_player_control_get_buffered_time_impl get_buffered_time;
-  meego_media_player_control_get_buffered_bytes_impl get_buffered_bytes;
-  meego_media_player_control_get_media_size_time_impl get_media_size_time;
-  meego_media_player_control_get_media_size_bytes_impl get_media_size_bytes;
-  meego_media_player_control_has_video_impl has_video;
-  meego_media_player_control_has_audio_impl has_audio;
-  meego_media_player_control_is_streaming_impl is_streaming;
-  meego_media_player_control_is_seekable_impl is_seekable;
-  meego_media_player_control_support_fullscreen_impl support_fullscreen;
-  meego_media_player_control_get_player_state_impl get_player_state;
-  meego_media_player_control_get_current_video_impl get_current_video;
-  meego_media_player_control_get_current_audio_impl get_current_audio;
-  meego_media_player_control_set_current_video_impl set_current_video;
-  meego_media_player_control_set_current_audio_impl set_current_audio;
-  meego_media_player_control_get_video_num_impl get_video_num;
-  meego_media_player_control_get_audio_num_impl get_audio_num;
-  meego_media_player_control_set_proxy_impl set_proxy;
-  meego_media_player_control_set_subtitle_uri_impl set_subtitle_uri;
-  meego_media_player_control_get_audio_num_impl get_subtitle_num;
-  meego_media_player_control_get_current_subtitle_impl get_current_subtitle;
-  meego_media_player_control_set_current_subtitle_impl set_current_subtitle;
-  meego_media_player_control_set_buffer_depth_impl set_buffer_depth;
-  meego_media_player_control_get_buffer_depth_impl get_buffer_depth;
-  meego_media_player_control_set_mute_impl set_mute;
-  meego_media_player_control_is_mute_impl is_mute;
-  meego_media_player_control_set_scale_mode_impl set_scale_mode;
-  meego_media_player_control_get_scale_mode_impl get_scale_mode;
-  meego_media_player_control_suspend_impl suspend;
-  meego_media_player_control_restore_impl restore;
-  meego_media_player_control_get_video_codec_impl get_video_codec;
-  meego_media_player_control_get_audio_codec_impl get_audio_codec;
-  meego_media_player_control_get_video_bitrate_impl get_video_bitrate;
-  meego_media_player_control_get_audio_bitrate_impl get_audio_bitrate;
-  meego_media_player_control_get_encapsulation_impl get_encapsulation;
-  meego_media_player_control_get_audio_samplerate_impl get_audio_samplerate;
-  meego_media_player_control_get_video_framerate_impl get_video_framerate;
-  meego_media_player_control_get_video_resolution_impl get_video_resolution;
-  meego_media_player_control_get_video_aspect_ratio_impl get_video_aspect_ratio;
-  meego_media_player_control_get_protocol_name_impl get_protocol_name;
-  meego_media_player_control_get_current_uri_impl get_current_uri;
-  meego_media_player_control_get_title_impl get_title;
-  meego_media_player_control_get_artist_impl get_artist;
-  meego_media_player_control_record_impl record;
-  meego_media_player_control_get_pat_impl get_pat;
-  meego_media_player_control_get_pmt_impl get_pmt;
-  meego_media_player_control_get_associated_data_channel_impl get_associated_data_channel;
-};
-
-enum {
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Initialized,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_EOF,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Error,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Seeked,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Stopped,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_RequestWindow,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Buffering,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Buffered,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_PlayerStateChanged,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_TargetReady,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Suspended,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Restored,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_VideoTagChanged,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_AudioTagChanged,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_TextTagChanged,
-  SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_MetadataChanged,
-  N_MEEGO_MEDIA_PLAYER_CONTROL_SIGNALS
-};
-static guint meego_media_player_control_signals[N_MEEGO_MEDIA_PLAYER_CONTROL_SIGNALS] = {0};
-
-static void meego_media_player_control_base_init (gpointer klass);
-
-GType
-meego_media_player_control_get_type (void)
-{
-  static GType type = 0;
-
-  if (G_UNLIKELY (type == 0)) {
-    static const GTypeInfo info = {
-      sizeof (MeegoMediaPlayerControlClass),
-      meego_media_player_control_base_init, /* base_init */
-      NULL, /* base_finalize */
-      NULL, /* class_init */
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      0,
-      0, /* n_preallocs */
-      NULL /* instance_init */
-    };
-
-    type = g_type_register_static (G_TYPE_INTERFACE,
-           "MeegoMediaPlayerControl", &info, 0);
-  }
-
-  return type;
-}
-
-gboolean
-meego_media_player_control_set_uri (MeegoMediaPlayerControl *self,
-    const gchar *in_uri)
-{
-  meego_media_player_control_set_uri_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_uri);
-
-  if (impl != NULL) {
-    (impl) (self,
-            in_uri);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_uri (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_uri_impl impl)
-{
-  klass->set_uri = impl;
-}
-
-gboolean
-meego_media_player_control_set_target (MeegoMediaPlayerControl *self,
-    gint type, GHashTable *params)
-{
-  meego_media_player_control_set_target_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_target);
-
-  if (impl != NULL) {
-    (impl) (self, type, params);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_target (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_target_impl impl)
-{
-  klass->set_target = impl;
-}
-
-
-
-gboolean
-meego_media_player_control_play (MeegoMediaPlayerControl *self)
-{
-  meego_media_player_control_play_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->play);
-
-  if (impl != NULL) {
-    (impl) (self);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_play (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_play_impl impl)
-{
-  klass->play = impl;
-}
-
-gboolean
-meego_media_player_control_pause (MeegoMediaPlayerControl *self)
-{
-  meego_media_player_control_pause_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->pause);
-
-  if (impl != NULL) {
-    (impl) (self);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_pause (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_pause_impl impl)
-{
-  klass->pause = impl;
-}
-
-gboolean
-meego_media_player_control_stop (MeegoMediaPlayerControl *self)
-{
-  meego_media_player_control_stop_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->stop);
-
-  if (impl != NULL) {
-    (impl) (self);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_stop (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_stop_impl impl)
-{
-  klass->stop = impl;
-}
-
-
-gboolean
-meego_media_player_control_set_position (MeegoMediaPlayerControl *self,
-    gint64 in_pos)
-{
-  meego_media_player_control_set_position_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_position);
-
-  if (impl != NULL) {
-    (impl) (self,
-            in_pos);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_position (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_position_impl impl)
-{
-  klass->set_position = impl;
-}
-
-gboolean
-meego_media_player_control_get_position (MeegoMediaPlayerControl *self, gint64 *cur_time)
-{
-  gboolean ret = FALSE;
-  meego_media_player_control_get_position_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_position);
-
-  if (impl != NULL) {
-    ret = (impl) (self, cur_time);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return ret;
-}
-
-
-void meego_media_player_control_implement_get_position (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_position_impl impl)
-{
-  klass->get_position = impl;
-}
-
-
-gboolean
-meego_media_player_control_set_playback_rate (MeegoMediaPlayerControl *self,
-    gdouble in_rate)
-{
-  meego_media_player_control_set_playback_rate_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_playback_rate);
-
-  if (impl != NULL) {
-    return (impl) (self,
-                   in_rate);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_playback_rate (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_playback_rate_impl impl)
-{
-  klass->set_playback_rate = impl;
-}
-
-gboolean
-meego_media_player_control_get_playback_rate (MeegoMediaPlayerControl *self, gdouble *out_rate)
-{
-  meego_media_player_control_get_playback_rate_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_playback_rate);
-
-  if (impl != NULL) {
-    (impl) (self, out_rate);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_playback_rate (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_playback_rate_impl impl)
-{
-  klass->get_playback_rate = impl;
-}
-
-
-gboolean
-meego_media_player_control_set_volume (MeegoMediaPlayerControl *self,
-    gint in_volume)
-{
-  meego_media_player_control_set_volume_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_volume);
-
-  if (impl != NULL) {
-    (impl) (self,
-            in_volume);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_volume (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_volume_impl impl)
-{
-  klass->set_volume = impl;
-}
-
-gboolean
-meego_media_player_control_get_volume (MeegoMediaPlayerControl *self, gint *vol)
-{
-  meego_media_player_control_get_volume_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_volume);
-
-  if (impl != NULL) {
-    (impl) (self, vol);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_volume (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_volume_impl impl)
-{
-  klass->get_volume = impl;
-}
-
-
-gboolean
-meego_media_player_control_set_window_id (MeegoMediaPlayerControl *self,
-    gdouble in_win_id)
-{
-  meego_media_player_control_set_window_id_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_window_id);
-
-  if (impl != NULL) {
-    (impl) (self,
-            in_win_id);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_window_id (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_window_id_impl impl)
-{
-  klass->set_window_id = impl;
-}
-
-
-
-
-
-gboolean
-meego_media_player_control_set_video_size (MeegoMediaPlayerControl *self,
-    guint in_x,
-    guint in_y,
-    guint in_w,
-    guint in_h)
-{
-  meego_media_player_control_set_video_size_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_video_size);
-
-  if (impl != NULL) {
-    (impl) (self,
-            in_x,
-            in_y,
-            in_w,
-            in_h);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_video_size (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_video_size_impl impl)
-{
-  klass->set_video_size = impl;
-}
-
-gboolean
-meego_media_player_control_get_video_size (MeegoMediaPlayerControl *self, guint *w, guint *h)
-{
-  meego_media_player_control_get_video_size_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_size);
-
-  if (impl != NULL) {
-    (impl) (self, w, h);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_video_size (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_size_impl impl)
-{
-  klass->get_video_size = impl;
-}
-
-gboolean
-meego_media_player_control_get_buffered_time (MeegoMediaPlayerControl *self, gint64 *buffered_time)
-{
-  meego_media_player_control_get_buffered_time_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_buffered_time);
-
-  if (impl != NULL) {
-    (impl) (self, buffered_time);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_buffered_time (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_buffered_time_impl impl)
-{
-  klass->get_buffered_time = impl;
-}
-
-gboolean
-meego_media_player_control_get_buffered_bytes (MeegoMediaPlayerControl *self, gint64 *buffered_time)
-{
-  meego_media_player_control_get_buffered_bytes_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_buffered_bytes);
-
-  if (impl != NULL) {
-    (impl) (self, buffered_time);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_buffered_bytes (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_buffered_bytes_impl impl)
-{
-  klass->get_buffered_bytes = impl;
-}
-
-gboolean
-meego_media_player_control_get_media_size_time (MeegoMediaPlayerControl *self, gint64 *media_size_time)
-{
-  meego_media_player_control_get_media_size_time_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_media_size_time);
-
-  if (impl != NULL) {
-    (impl) (self, media_size_time);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_media_size_time (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_media_size_time_impl impl)
-{
-  klass->get_media_size_time = impl;
-}
-
-gboolean
-meego_media_player_control_get_media_size_bytes (MeegoMediaPlayerControl *self, gint64 *media_size_bytes)
-{
-  meego_media_player_control_get_media_size_bytes_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_media_size_bytes);
-
-  if (impl != NULL) {
-    (impl) (self, media_size_bytes);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_media_size_bytes (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_media_size_bytes_impl impl)
-{
-  klass->get_media_size_bytes = impl;
-}
-
-gboolean
-meego_media_player_control_has_video (MeegoMediaPlayerControl *self, gboolean *has_video)
-{
-  meego_media_player_control_has_video_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->has_video);
-
-  if (impl != NULL) {
-    (impl) (self, has_video);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_has_video (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_has_video_impl impl)
-{
-  klass->has_video = impl;
-}
-
-gboolean
-meego_media_player_control_has_audio (MeegoMediaPlayerControl *self, gboolean *has_audio)
-{
-  meego_media_player_control_has_audio_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->has_audio);
-
-  if (impl != NULL) {
-    (impl) (self, has_audio);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_has_audio (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_has_audio_impl impl)
-{
-  klass->has_audio = impl;
-}
-
-gboolean
-meego_media_player_control_is_streaming (MeegoMediaPlayerControl *self, gboolean *is_streaming)
-{
-  meego_media_player_control_is_streaming_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->is_streaming);
-
-  if (impl != NULL) {
-    (impl) (self, is_streaming);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_is_streaming (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_is_streaming_impl impl)
-{
-  klass->is_streaming = impl;
-}
-
-gboolean
-meego_media_player_control_is_seekable (MeegoMediaPlayerControl *self, gboolean *seekable)
-{
-  meego_media_player_control_is_seekable_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->is_seekable);
-
-  if (impl != NULL) {
-    (impl) (self, seekable);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_is_seekable (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_is_seekable_impl impl)
-{
-  klass->is_seekable = impl;
-}
-
-gboolean
-meego_media_player_control_support_fullscreen (MeegoMediaPlayerControl *self, gboolean *support_fullscreen)
-{
-  meego_media_player_control_support_fullscreen_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->support_fullscreen);
-
-  if (impl != NULL) {
-    (impl) (self, support_fullscreen);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_support_fullscreen (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_support_fullscreen_impl impl)
-{
-  klass->support_fullscreen = impl;
-}
-
-gboolean
-meego_media_player_control_get_player_state (MeegoMediaPlayerControl *self, gint *state)
-{
-  meego_media_player_control_get_player_state_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_player_state);
-
-  if (impl != NULL) {
-    (impl) (self, state);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_player_state (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_player_state_impl impl)
-{
-  klass->get_player_state = impl;
-}
-
-
-gboolean
-meego_media_player_control_get_current_video (MeegoMediaPlayerControl *self, gint *cur_video)
-{
-  meego_media_player_control_get_current_video_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_current_video);
-
-  if (impl != NULL) {
-    (impl) (self, cur_video);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_current_video (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_current_video_impl impl)
-{
-  klass->get_current_video = impl;
-}
-
-
-gboolean
-meego_media_player_control_get_current_audio (MeegoMediaPlayerControl *self, gint *cur_audio)
-{
-  meego_media_player_control_get_current_audio_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_current_audio);
-
-  if (impl != NULL) {
-    (impl) (self, cur_audio);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_current_audio (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_current_audio_impl impl)
-{
-  klass->get_current_audio = impl;
-}
-
-
-gboolean
-meego_media_player_control_set_current_video (MeegoMediaPlayerControl *self, gint cur_video)
-{
-  meego_media_player_control_set_current_video_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_current_video);
-
-  if (impl != NULL) {
-    (impl) (self, cur_video);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_current_video (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_current_video_impl impl)
-{
-  klass->set_current_video = impl;
-}
-
-
-gboolean
-meego_media_player_control_set_current_audio (MeegoMediaPlayerControl *self, gint cur_audio)
-{
-  meego_media_player_control_set_current_audio_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_current_audio);
-
-  if (impl != NULL) {
-    (impl) (self, cur_audio);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_set_current_audio (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_current_audio_impl impl)
-{
-  klass->set_current_audio = impl;
-}
-
-
-gboolean
-meego_media_player_control_get_video_num (MeegoMediaPlayerControl *self, gint *video_num)
-{
-  meego_media_player_control_get_video_num_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_num);
-
-  if (impl != NULL) {
-    (impl) (self, video_num);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_video_num (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_num_impl impl)
-{
-  klass->get_video_num = impl;
-}
-
-
-gboolean
-meego_media_player_control_get_audio_num (MeegoMediaPlayerControl *self, gint *audio_num)
-{
-  meego_media_player_control_get_audio_num_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_audio_num);
-
-  if (impl != NULL) {
-    (impl) (self, audio_num);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-
-void meego_media_player_control_implement_get_audio_num (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_audio_num_impl impl)
-{
-  klass->get_audio_num = impl;
-}
-
-gboolean
-meego_media_player_control_set_proxy (MeegoMediaPlayerControl *self,
-    GHashTable *params)
-{
-  meego_media_player_control_set_proxy_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_proxy);
-
-  if (impl != NULL) {
-    (impl) (self, params);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_proxy (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_proxy_impl impl)
-{
-  klass->set_proxy = impl;
-}
-
-gboolean
-meego_media_player_control_set_subtitle_uri (MeegoMediaPlayerControl *self, gchar *sub_uri)
-{
-  meego_media_player_control_set_subtitle_uri_impl impl = (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_subtitle_uri);
-
-  if (impl != NULL) {
-    (impl) (self, sub_uri);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_subtitle_uri (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_subtitle_uri_impl impl)
-{
-  klass->set_subtitle_uri = impl;
-}
-
-gboolean
-meego_media_player_control_get_subtitle_num (MeegoMediaPlayerControl *self, gint *sub_num)
-{
-  meego_media_player_control_get_subtitle_num_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_subtitle_num);
-
-  if (impl != NULL) {
-    (impl) (self, sub_num);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_subtitle_num (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_subtitle_num_impl impl)
-{
-  klass->get_subtitle_num = impl;
-}
-
-gboolean
-meego_media_player_control_get_current_subtitle (MeegoMediaPlayerControl *self, gint *cur_sub)
-{
-  meego_media_player_control_get_current_subtitle_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_current_subtitle);
-
-  if (impl != NULL) {
-    (impl) (self, cur_sub);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_current_subtitle (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_current_subtitle_impl impl)
-{
-  klass->get_current_subtitle = impl;
-}
-
-gboolean
-meego_media_player_control_set_current_subtitle (MeegoMediaPlayerControl *self, gint cur_sub)
-{
-  meego_media_player_control_set_current_subtitle_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_current_subtitle);
-
-  if (impl != NULL) {
-    (impl) (self, cur_sub);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_current_subtitle (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_current_subtitle_impl impl)
-{
-  klass->set_current_subtitle = impl;
-}
-
-gboolean
-meego_media_player_control_set_buffer_depth (MeegoMediaPlayerControl *self, gint format, gint64 buf_val)
-{
-  meego_media_player_control_set_buffer_depth_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_buffer_depth);
-
-  if (impl != NULL) {
-    (impl) (self, format, buf_val);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_buffer_depth (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_buffer_depth_impl impl)
-{
-  klass->set_buffer_depth = impl;
-}
-
-gboolean
-meego_media_player_control_get_buffer_depth (MeegoMediaPlayerControl *self, gint format, gint64 *buf_val)
-{
-  meego_media_player_control_get_buffer_depth_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_buffer_depth);
-
-  if (impl != NULL) {
-    (impl) (self, format, buf_val);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_buffer_depth (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_buffer_depth_impl impl)
-{
-  klass->get_buffer_depth = impl;
-}
-
-gboolean
-meego_media_player_control_set_mute (MeegoMediaPlayerControl *self, gint mute)
-{
-  meego_media_player_control_set_mute_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_mute);
-
-  if (impl != NULL) {
-    (impl) (self, mute);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_mute (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_mute_impl impl)
-{
-  klass->set_mute = impl;
-}
-
-gboolean
-meego_media_player_control_is_mute (MeegoMediaPlayerControl *self, gint *mute)
-{
-  meego_media_player_control_is_mute_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->is_mute);
-
-  if (impl != NULL) {
-    (impl) (self, mute);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_is_mute (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_is_mute_impl impl)
-{
-  klass->is_mute = impl;
-}
-
-gboolean meego_media_player_control_set_scale_mode (MeegoMediaPlayerControl *self, gint scale_mode)
-{
-  meego_media_player_control_set_scale_mode_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->set_scale_mode);
-
-  if (impl != NULL) {
-    (impl) (self, scale_mode);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_set_scale_mode (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_set_scale_mode_impl impl)
-{
-  klass->set_scale_mode = impl;
-}
-
-gboolean meego_media_player_control_get_scale_mode (MeegoMediaPlayerControl *self, gint *scale_mode)
-{
-  meego_media_player_control_get_scale_mode_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_scale_mode);
-
-  if (impl != NULL) {
-    (impl) (self, scale_mode);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_scale_mode (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_scale_mode_impl impl)
-{
-  klass->get_scale_mode = impl;
-}
-
-gboolean meego_media_player_control_suspend (MeegoMediaPlayerControl *self)
-{
-  meego_media_player_control_suspend_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->suspend);
-
-  if (impl != NULL) {
-    (impl) (self);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_suspend (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_suspend_impl impl)
-{
-  klass->suspend = impl;
-}
-
-gboolean meego_media_player_control_restore (MeegoMediaPlayerControl *self)
-{
-  meego_media_player_control_restore_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->restore);
-
-  if (impl != NULL) {
-    (impl) (self);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_restore (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_restore_impl impl)
-{
-  klass->restore = impl;
-}
-
-gboolean meego_media_player_control_get_video_codec (MeegoMediaPlayerControl *self,
-    gint channel,
-    gchar **video_codec)
-{
-  meego_media_player_control_get_video_codec_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_codec);
-
-  if (impl != NULL) {
-    (impl) (self, channel, video_codec);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_video_codec (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_codec_impl impl)
-{
-  klass->get_video_codec = impl;
-}
-
-gboolean meego_media_player_control_get_audio_codec (MeegoMediaPlayerControl *self,
-    gint channel,
-    gchar **audio_codec)
-{
-  meego_media_player_control_get_audio_codec_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_audio_codec);
-
-  if (impl != NULL) {
-    (impl) (self, channel, audio_codec);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_audio_codec (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_audio_codec_impl impl)
-{
-  klass->get_audio_codec = impl;
-}
-
-gboolean meego_media_player_control_get_video_bitrate (MeegoMediaPlayerControl *self, gint channel, gint *bit_rate)
-{
-  meego_media_player_control_get_video_bitrate_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_bitrate);
-
-  if (impl != NULL) {
-    (impl) (self, channel, bit_rate);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_video_bitrate (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_bitrate_impl impl)
-{
-  klass->get_video_bitrate = impl;
-}
-
-gboolean meego_media_player_control_get_audio_bitrate (MeegoMediaPlayerControl *self, gint channel, gint *bit_rate)
-{
-  meego_media_player_control_get_audio_bitrate_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_audio_bitrate);
-
-  if (impl != NULL) {
-    (impl) (self, channel, bit_rate);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_audio_bitrate (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_audio_bitrate_impl impl)
-{
-  klass->get_audio_bitrate = impl;
-}
-
-gboolean meego_media_player_control_get_encapsulation(MeegoMediaPlayerControl *self, gchar ** encapsulation)
-{
-  meego_media_player_control_get_encapsulation_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_encapsulation);
-
-  if (impl != NULL) {
-    (impl) (self, encapsulation);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_encapsulation (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_encapsulation_impl impl)
-{
-  klass->get_encapsulation = impl;
-}
-
-gboolean meego_media_player_control_get_audio_samplerate(MeegoMediaPlayerControl *self, gint channel,
-    gint * sample_rate)
-{
-  meego_media_player_control_get_audio_samplerate_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_audio_samplerate);
-
-  if (impl != NULL) {
-    (impl) (self, channel, sample_rate);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_audio_samplerate (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_audio_samplerate_impl impl)
-{
-  klass->get_audio_samplerate = impl;
-}
-
-gboolean meego_media_player_control_get_video_framerate(MeegoMediaPlayerControl *self, gint channel,
-    gint * frame_rate_num, gint * frame_rate_denom)
-{
-  meego_media_player_control_get_video_framerate_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_framerate);
-
-  if (impl != NULL) {
-    (impl) (self, channel, frame_rate_num, frame_rate_denom);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_video_framerate (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_framerate_impl impl)
-{
-  klass->get_video_framerate = impl;
-}
-
-gboolean meego_media_player_control_get_video_resolution(MeegoMediaPlayerControl *self, gint channel,
-    gint * width, gint * height)
-{
-  meego_media_player_control_get_video_resolution_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_resolution);
-
-  if (impl != NULL) {
-    (impl) (self, channel, width, height);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_video_resolution(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_resolution_impl impl)
-{
-  klass->get_video_resolution = impl;
-}
-
-
-gboolean meego_media_player_control_get_video_aspect_ratio(MeegoMediaPlayerControl *self,
-    gint channel, gint * ratio_num, gint * ratio_denom)
-{
-  meego_media_player_control_get_video_aspect_ratio_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_video_aspect_ratio);
-
-  if (impl != NULL) {
-    (impl) (self, channel, ratio_num, ratio_denom);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_video_aspect_ratio(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_video_aspect_ratio_impl impl)
-{
-  klass->get_video_aspect_ratio = impl;
-}
-
-gboolean meego_media_player_control_get_protocol_name(MeegoMediaPlayerControl *self, gchar ** prot_name)
-{
-  meego_media_player_control_get_protocol_name_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_protocol_name);
-
-  if (impl != NULL) {
-    (impl) (self, prot_name);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_protocol_name(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_protocol_name_impl impl)
-{
-  klass->get_protocol_name = impl;
-}
-
-gboolean meego_media_player_control_get_current_uri(MeegoMediaPlayerControl *self, gchar ** uri)
-{
-  meego_media_player_control_get_current_uri_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_current_uri);
-
-  if (impl != NULL) {
-    (impl) (self, uri);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_current_uri(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_current_uri_impl impl)
-{
-  klass->get_current_uri = impl;
-}
-
-gboolean meego_media_player_control_get_title (MeegoMediaPlayerControl *self, gchar ** title)
-{
-  meego_media_player_control_get_title_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_title);
-
-  if (impl != NULL) {
-    (impl) (self, title);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_title(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_title_impl impl)
-{
-  klass->get_title = impl;
-}
-
-gboolean meego_media_player_control_get_artist(MeegoMediaPlayerControl *self, gchar ** artist)
-{
-  meego_media_player_control_get_artist_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_artist);
-
-  if (impl != NULL) {
-    (impl) (self, artist);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_artist(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_artist_impl impl)
-{
-  klass->get_artist = impl;
-}
-
-gboolean meego_media_player_control_record (MeegoMediaPlayerControl *self, gboolean to_record, gchar *location)
-{
-  gboolean ret = FALSE;
-  meego_media_player_control_record_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->record);
-
-  if (impl != NULL) {
-    ret = (impl) (self, to_record, location);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return ret;
-}
-
-void meego_media_player_control_implement_record  (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_record_impl impl)
-{
-  klass->record = impl;
-}
-
-gboolean meego_media_player_control_get_pat (MeegoMediaPlayerControl *self, GPtrArray **pat)
-{
-  meego_media_player_control_get_pat_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_pat);
-
-  if (impl != NULL) {
-    (impl) (self, pat);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_pat(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_pat_impl impl)
-{
-  klass->get_pat = impl;
-}
-
-gboolean meego_media_player_control_get_pmt (MeegoMediaPlayerControl *self, guint *program_num, guint *pcr_pid, 
-                                             GPtrArray **stream_info)
-{
-  meego_media_player_control_get_pmt_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_pmt);
-
-  if (impl != NULL) {
-    (impl) (self, program_num, pcr_pid, stream_info);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_pmt(MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_pmt_impl impl)
-{
-  klass->get_pmt = impl;
-}
-
-gboolean 
-meego_media_player_control_get_associated_data_channel (MeegoMediaPlayerControl *self, gchar **ip, gint *port)
-{
-  meego_media_player_control_get_associated_data_channel_impl impl =
-    (MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS (self)->get_associated_data_channel);
-
-  if (impl != NULL) {
-    (impl) (self, ip, port);
-  } else {
-    g_warning ("Method not implemented\n");
-  }
-  return TRUE;
-}
-
-void meego_media_player_control_implement_get_associated_data_channel (MeegoMediaPlayerControlClass *klass,
-    meego_media_player_control_get_associated_data_channel_impl impl)
-{
-  klass->get_associated_data_channel = impl;
-}
-
-void
-meego_media_player_control_emit_initialized (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Initialized],
-                 0);
-}
-void
-meego_media_player_control_emit_eof (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_EOF],
-                 0);
-}
-
-void
-meego_media_player_control_emit_error (gpointer instance,
-    guint error_num, gchar *error_des)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Error],
-                 0,
-                 error_num, error_des);
-}
-
-void
-meego_media_player_control_emit_buffered (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Buffered],
-                 0);
-}
-void
-meego_media_player_control_emit_buffering (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Buffering],
-                 0);
-}
-
-void
-meego_media_player_control_emit_player_state_changed (gpointer instance, gint old_state, gint new_state)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_PlayerStateChanged],
-                 0, old_state, new_state);
-}
-
-void
-meego_media_player_control_emit_target_ready (gpointer instance, GHashTable *infos)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_TargetReady],
-                 0, infos);
-}
-void
-meego_media_player_control_emit_seeked (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Seeked],
-                 0);
-}
-void
-meego_media_player_control_emit_stopped (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Stopped],
-                 0);
-}
-
-void
-meego_media_player_control_emit_request_window (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_RequestWindow],
-                 0);
-}
-
-void
-meego_media_player_control_emit_suspended (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Suspended],
-                 0);
-}
-
-void
-meego_media_player_control_emit_restored (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Restored],
-                 0);
-}
-
-void
-meego_media_player_control_emit_video_tag_changed (gpointer instance, gint channel)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_VideoTagChanged],
-                 0, channel);
-}
-
-void
-meego_media_player_control_emit_audio_tag_changed (gpointer instance, gint channel)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_AudioTagChanged],
-                 0, channel);
-}
-
-void
-meego_media_player_control_emit_text_tag_changed (gpointer instance, gint channel)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_TextTagChanged],
-                 0, channel);
-}
-
-void
-meego_media_player_control_emit_metadata_changed (gpointer instance)
-{
-  g_assert (instance != NULL);
-  g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, MEEGO_TYPE_MEDIA_PLAYER_CONTROL));
-  g_signal_emit (instance,
-                 meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_MetadataChanged],
-                 0);
-}
-
-static inline void
-meego_media_player_control_base_init_once (gpointer klass G_GNUC_UNUSED)
-{
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Initialized] =
-    g_signal_new ("initialized",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_EOF] =
-    g_signal_new ("eof",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Error] =
-    g_signal_new ("error",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  umms_marshal_VOID__UINT_STRING,
-                  G_TYPE_NONE,
-                  2,
-                  G_TYPE_UINT,
-                  G_TYPE_STRING);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Seeked] =
-    g_signal_new ("seeked",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Stopped] =
-    g_signal_new ("stopped",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_RequestWindow] =
-    g_signal_new ("request-window",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Buffering] =
-    g_signal_new ("buffering",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Buffered] =
-    g_signal_new ("buffered",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_PlayerStateChanged] =
-    g_signal_new ("player-state-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  umms_marshal_VOID__INT_INT,
-                  G_TYPE_NONE,
-                  2,
-                  G_TYPE_INT,
-                  G_TYPE_INT);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_TargetReady] =
-    g_signal_new ("target-ready",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__BOXED,
-                  G_TYPE_NONE,
-                  1, dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Suspended] =
-    g_signal_new ("suspended",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_Restored] =
-    g_signal_new ("restored",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_VideoTagChanged] =
-    g_signal_new ("video-tag-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__INT,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_INT);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_AudioTagChanged] =
-    g_signal_new ("audio-tag-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__INT,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_INT);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_TextTagChanged] =
-    g_signal_new ("text-tag-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__INT,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_INT);
-
-  meego_media_player_control_signals[SIGNAL_MEEGO_MEDIA_PLAYER_CONTROL_MetadataChanged] =
-    g_signal_new ("metadata-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-}
-
-static void
-meego_media_player_control_base_init (gpointer klass)
-{
-  static gboolean initialized = FALSE;
-
-  if (!initialized) {
-    initialized = TRUE;
-    meego_media_player_control_base_init_once (klass);
-  }
-}
--- src/meego-media-player-control.h
+++ src/meego-media-player-control.h
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __MEEGO_MEDIA_PLAYER_CONTROL_H__
-#define __MEEGO_MEDIA_PLAYER_CONTROL_H__
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/**
- * MeegoMediaPlayerControl:
- *
- * Dummy typedef representing any implementation of this interface.
- */
-typedef struct _MeegoMediaPlayerControl MeegoMediaPlayerControl;
-
-/**
- * MeegoMediaPlayerControlClass:
- *
- * The class of MeegoMediaPlayerControl.
- */
-typedef struct _MeegoMediaPlayerControlClass MeegoMediaPlayerControlClass;
-
-GType meego_media_player_control_get_type (void);
-#define MEEGO_TYPE_MEDIA_PLAYER_CONTROL \
-  (meego_media_player_control_get_type ())
-#define MEEGO_MEDIA_PLAYER_CONTROL(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj), MEEGO_TYPE_MEDIA_PLAYER_CONTROL, MeegoMediaPlayerControl))
-#define MEEGO_IS_MEDIA_PLAYER_CONTROL(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj), MEEGO_TYPE_MEDIA_PLAYER_CONTROL))
-#define MEEGO_MEDIA_PLAYER_CONTROL_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_INTERFACE((obj), MEEGO_TYPE_MEDIA_PLAYER_CONTROL, MeegoMediaPlayerControlClass))
-
-
-typedef gboolean (*meego_media_player_control_set_uri_impl) (MeegoMediaPlayerControl *self, const gchar *in_uri);
-void meego_media_player_control_implement_set_uri (MeegoMediaPlayerControlClass *klass, 
-                                                   meego_media_player_control_set_uri_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_target_impl) (MeegoMediaPlayerControl *self,
-                                                                gint type, GHashTable *params);
-void meego_media_player_control_implement_set_target (MeegoMediaPlayerControlClass *klass,
-                                                      meego_media_player_control_set_target_impl impl);
-
-typedef gboolean (*meego_media_player_control_play_impl) (MeegoMediaPlayerControl *self);
-void meego_media_player_control_implement_play (MeegoMediaPlayerControlClass *klass, 
-                                                meego_media_player_control_play_impl impl);
-
-typedef gboolean (*meego_media_player_control_pause_impl) (MeegoMediaPlayerControl *self);
-void meego_media_player_control_implement_pause (MeegoMediaPlayerControlClass *klass,
-                                                 meego_media_player_control_pause_impl impl);
-
-typedef gboolean (*meego_media_player_control_stop_impl) (MeegoMediaPlayerControl *self);
-void meego_media_player_control_implement_stop (MeegoMediaPlayerControlClass *klass, 
-                                                meego_media_player_control_stop_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_position_impl) (MeegoMediaPlayerControl *self, gint64 in_pos);
-void meego_media_player_control_implement_set_position (MeegoMediaPlayerControlClass *klass, 
-                                                        meego_media_player_control_set_position_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_position_impl) (MeegoMediaPlayerControl *self, gint64 *cur_time);
-void meego_media_player_control_implement_get_position (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_position_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_playback_rate_impl) (MeegoMediaPlayerControl *self, gdouble in_rate);
-void meego_media_player_control_implement_set_playback_rate (MeegoMediaPlayerControlClass *klass, 
-                                                            meego_media_player_control_set_playback_rate_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_playback_rate_impl) (MeegoMediaPlayerControl *self, gdouble *out_rate);
-void meego_media_player_control_implement_get_playback_rate (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_playback_rate_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_volume_impl) (MeegoMediaPlayerControl *self, gint in_volume);
-void meego_media_player_control_implement_set_volume (MeegoMediaPlayerControlClass *klass, 
-                                                    meego_media_player_control_set_volume_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_volume_impl) (MeegoMediaPlayerControl *self, gint *vol);
-void meego_media_player_control_implement_get_volume (MeegoMediaPlayerControlClass *klass,
-                                                      meego_media_player_control_get_volume_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_window_id_impl) (MeegoMediaPlayerControl *self, gdouble in_win_id);
-void meego_media_player_control_implement_set_window_id (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_window_id_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_video_size_impl) (MeegoMediaPlayerControl *self,
-                    guint in_x,
-                    guint in_y,
-                    guint in_w,
-                    guint in_h);
-void meego_media_player_control_implement_set_video_size (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_video_size_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_size_impl) (MeegoMediaPlayerControl *self, guint *w, guint *h);
-void meego_media_player_control_implement_get_video_size (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_size_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_buffered_bytes_impl) (MeegoMediaPlayerControl *self, gint64 *depth);
-void meego_media_player_control_implement_get_buffered_bytes (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_buffered_bytes_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_buffered_time_impl) (MeegoMediaPlayerControl *self, gint64 *depth);
-void meego_media_player_control_implement_get_buffered_time (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_buffered_time_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_media_size_time_impl) (MeegoMediaPlayerControl *self, gint64 *media_size_time);
-void meego_media_player_control_implement_get_media_size_time (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_media_size_time_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_media_size_bytes_impl) (MeegoMediaPlayerControl *self, gint64 *media_size_bytes);
-void meego_media_player_control_implement_get_media_size_bytes (MeegoMediaPlayerControlClass *klass,
-                                                            meego_media_player_control_get_media_size_bytes_impl impl);
-
-typedef gboolean (*meego_media_player_control_has_audio_impl) (MeegoMediaPlayerControl *self, gboolean *has_audio);
-void meego_media_player_control_implement_has_audio (MeegoMediaPlayerControlClass *klass,
-                                                     meego_media_player_control_has_audio_impl impl);
-
-typedef gboolean (*meego_media_player_control_has_video_impl) (MeegoMediaPlayerControl *self, gboolean *has_video);
-void meego_media_player_control_implement_has_video (MeegoMediaPlayerControlClass *klass,
-                                                     meego_media_player_control_has_video_impl impl);
-
-typedef gboolean (*meego_media_player_control_is_streaming_impl) (MeegoMediaPlayerControl *self, gboolean *is_streaming);
-void meego_media_player_control_implement_is_streaming (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_is_streaming_impl impl);
-
-typedef gboolean (*meego_media_player_control_is_seekable_impl) (MeegoMediaPlayerControl *self, gboolean *seekable);
-void meego_media_player_control_implement_is_seekable (MeegoMediaPlayerControlClass *klass,
-                                                       meego_media_player_control_is_seekable_impl impl);
-
-typedef gboolean (*meego_media_player_control_support_fullscreen_impl) (MeegoMediaPlayerControl *self, gboolean *support_fullscreen);
-void meego_media_player_control_implement_support_fullscreen (MeegoMediaPlayerControlClass *klass,
-                                                            meego_media_player_control_support_fullscreen_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_player_state_impl) (MeegoMediaPlayerControl *self, gint *state);
-void meego_media_player_control_implement_get_player_state (MeegoMediaPlayerControlClass *klass, 
-                                                            meego_media_player_control_get_player_state_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_current_video_impl) (MeegoMediaPlayerControl *self, gint *cur_video);
-void meego_media_player_control_implement_get_current_video (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_current_video_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_current_audio_impl) (MeegoMediaPlayerControl *self, gint *cur_audio);
-void meego_media_player_control_implement_get_current_audio (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_current_audio_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_current_video_impl) (MeegoMediaPlayerControl *self, gint cur_video);
-void meego_media_player_control_implement_set_current_video (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_current_video_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_current_audio_impl) (MeegoMediaPlayerControl *self, gint cur_audio);
-void meego_media_player_control_implement_set_current_audio (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_current_audio_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_num_impl) (MeegoMediaPlayerControl *self, gint *video_num);
-void meego_media_player_control_implement_get_video_num (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_num_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_audio_num_impl) (MeegoMediaPlayerControl *self, gint *audio_num);
-void meego_media_player_control_implement_get_audio_num (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_audio_num_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_proxy_impl) (MeegoMediaPlayerControl *self,
-                                                                GHashTable *params);
-void meego_media_player_control_implement_set_proxy (MeegoMediaPlayerControlClass *klass,
-                                                      meego_media_player_control_set_proxy_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_subtitle_uri_impl) (MeegoMediaPlayerControl *self,
-                                                                      gchar *sub_uri);
-void meego_media_player_control_implement_set_subtitle_uri (MeegoMediaPlayerControlClass *klass,
-                                                            meego_media_player_control_set_subtitle_uri_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_subtitle_num_impl) (MeegoMediaPlayerControl *self, gint *subtitle_num);
-void meego_media_player_control_implement_get_subtitle_num (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_subtitle_num_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_current_subtitle_impl) (MeegoMediaPlayerControl *self, gint *cur_sub);
-void meego_media_player_control_implement_get_current_subtitle (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_current_subtitle_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_current_subtitle_impl) (MeegoMediaPlayerControl *self, gint cur_sub);
-void meego_media_player_control_implement_set_current_subtitle (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_current_subtitle_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_buffer_depth_impl) (MeegoMediaPlayerControl *self, 
-                                                                      gint format, gint64 buf_val);
-void meego_media_player_control_implement_set_buffer_depth (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_buffer_depth_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_buffer_depth_impl) (MeegoMediaPlayerControl *self, 
-                                                                      gint format, gint64 *buf_val);
-void meego_media_player_control_implement_get_buffer_depth (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_buffer_depth_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_mute_impl) (MeegoMediaPlayerControl *self, gint mute);
-void meego_media_player_control_implement_set_mute (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_mute_impl impl);
-
-typedef gboolean (*meego_media_player_control_is_mute_impl) (MeegoMediaPlayerControl *self, gint *mute);
-void meego_media_player_control_implement_is_mute (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_is_mute_impl impl);
-
-typedef gboolean (*meego_media_player_control_set_scale_mode_impl) (MeegoMediaPlayerControl *self, gint scale_mode);
-void meego_media_player_control_implement_set_scale_mode (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_set_scale_mode_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_scale_mode_impl) (MeegoMediaPlayerControl *self, gint *scale_mode);
-void meego_media_player_control_implement_get_scale_mode (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_scale_mode_impl impl);
-
-typedef gboolean (*meego_media_player_control_suspend_impl) (MeegoMediaPlayerControl *self);
-void meego_media_player_control_implement_suspend (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_suspend_impl impl);
-
-typedef gboolean (*meego_media_player_control_restore_impl) (MeegoMediaPlayerControl *self);
-void meego_media_player_control_implement_restore (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_restore_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_codec_impl) (MeegoMediaPlayerControl *self, 
-                                                        gint channel, gchar ** video_codec);
-void meego_media_player_control_implement_get_video_codec (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_codec_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_audio_codec_impl) (MeegoMediaPlayerControl *self, 
-                                                        gint channel, gchar ** audio_codec);
-void meego_media_player_control_implement_get_audio_codec (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_audio_codec_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_bitrate_impl) (MeegoMediaPlayerControl *self, gint channel, gint *bit_rate);
-void meego_media_player_control_implement_get_video_bitrate (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_bitrate_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_audio_bitrate_impl) (MeegoMediaPlayerControl *self, gint channel, gint *bit_rate);
-void meego_media_player_control_implement_get_audio_bitrate (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_audio_bitrate_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_encapsulation_impl) (MeegoMediaPlayerControl *self, 
-                                                        gchar ** encapsulation);
-void meego_media_player_control_implement_get_encapsulation (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_encapsulation_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_audio_samplerate_impl) (MeegoMediaPlayerControl *self, 
-                                                        gint channel, gint * sample_rate);
-void meego_media_player_control_implement_get_audio_samplerate (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_audio_samplerate_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_framerate_impl) (MeegoMediaPlayerControl *self, 
-                                                        gint channel, gint * frame_rate_num, gint * frame_rate_denom);
-void meego_media_player_control_implement_get_video_framerate (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_framerate_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_resolution_impl) (MeegoMediaPlayerControl *self,
-                                                        gint channel, gint * width, gint * height);
-void meego_media_player_control_implement_get_video_resolution(MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_resolution_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_video_aspect_ratio_impl) (MeegoMediaPlayerControl *self,
-                                                        gint channel, gint * ratio_num, gint * ratio_denom);
-void meego_media_player_control_implement_get_video_aspect_ratio(MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_video_aspect_ratio_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_protocol_name_impl) (MeegoMediaPlayerControl *self, gchar ** prot_name);
-void meego_media_player_control_implement_get_protocol_name(MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_protocol_name_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_current_uri_impl) (MeegoMediaPlayerControl *self, gchar ** uri);
-void meego_media_player_control_implement_get_current_uri(MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_current_uri_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_title_impl) (MeegoMediaPlayerControl *self, gchar ** uri);
-void meego_media_player_control_implement_get_title(MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_title_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_artist_impl) (MeegoMediaPlayerControl *self, gchar ** uri);
-void meego_media_player_control_implement_get_artist(MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_artist_impl impl);
-
-typedef gboolean (*meego_media_player_control_record_impl) (MeegoMediaPlayerControl *self, gboolean to_record, gchar *location);
-void meego_media_player_control_implement_record (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_record_impl impl);
-typedef gboolean (*meego_media_player_control_get_pat_impl) (MeegoMediaPlayerControl *self, GPtrArray **pat);
-void meego_media_player_control_implement_get_pat (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_pat_impl impl);
-typedef gboolean (*meego_media_player_control_get_pmt_impl) (MeegoMediaPlayerControl *self, 
-                                                            guint *program_num, guint *pcr_pid, GPtrArray **stream_info);
-void meego_media_player_control_implement_get_pmt (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_pmt_impl impl);
-
-typedef gboolean (*meego_media_player_control_get_associated_data_channel_impl) (MeegoMediaPlayerControl *self, gchar **ip, gint *port);
-void meego_media_player_control_implement_get_associated_data_channel (MeegoMediaPlayerControlClass *klass,
-                                                        meego_media_player_control_get_associated_data_channel_impl impl);
-
-
-/*virtual function wrappers*/
-gboolean meego_media_player_control_set_uri (MeegoMediaPlayerControl *self, const gchar *in_uri);
-gboolean meego_media_player_control_set_target (MeegoMediaPlayerControl *self, gint type, GHashTable *params);
-gboolean meego_media_player_control_play (MeegoMediaPlayerControl *self);
-gboolean meego_media_player_control_pause (MeegoMediaPlayerControl *self);
-gboolean meego_media_player_control_stop (MeegoMediaPlayerControl *self);
-gboolean meego_media_player_control_set_position (MeegoMediaPlayerControl *self, gint64 in_pos);
-gboolean meego_media_player_control_get_position (MeegoMediaPlayerControl *self, gint64 *cur_time);
-gboolean meego_media_player_control_set_playback_rate (MeegoMediaPlayerControl *self, gdouble in_rate);
-gboolean meego_media_player_control_get_playback_rate (MeegoMediaPlayerControl *self, gdouble *out_rate);
-gboolean meego_media_player_control_set_volume (MeegoMediaPlayerControl *self, gint in_volume);
-gboolean meego_media_player_control_get_volume (MeegoMediaPlayerControl *self, gint *vol);
-gboolean meego_media_player_control_set_window_id (MeegoMediaPlayerControl *self, gdouble in_win_id);
-gboolean meego_media_player_control_set_video_size (MeegoMediaPlayerControl *self, guint in_x, guint in_y, guint in_w, guint in_h);
-gboolean meego_media_player_control_get_video_size (MeegoMediaPlayerControl *self, guint *w, guint *h);
-gboolean meego_media_player_control_get_buffered_bytes (MeegoMediaPlayerControl *self, gint64 *buffered_bytes);
-gboolean meego_media_player_control_get_buffered_time (MeegoMediaPlayerControl *self, gint64 *buffered_time);
-gboolean meego_media_player_control_get_media_size_time (MeegoMediaPlayerControl *self, gint64 *media_size_time);
-gboolean meego_media_player_control_get_media_size_bytes (MeegoMediaPlayerControl *self, gint64 *media_size_bytes);
-gboolean meego_media_player_control_has_audio (MeegoMediaPlayerControl *self, gboolean *hav_audio);
-gboolean meego_media_player_control_has_video (MeegoMediaPlayerControl *self, gboolean *has_video);
-gboolean meego_media_player_control_is_streaming (MeegoMediaPlayerControl *self, gboolean *is_streaming);
-gboolean meego_media_player_control_is_seekable (MeegoMediaPlayerControl *self, gboolean *seekable);
-gboolean meego_media_player_control_support_fullscreen (MeegoMediaPlayerControl *self, gboolean *support_fullscreen);
-gboolean meego_media_player_control_get_player_state (MeegoMediaPlayerControl *self, gint *state);
-gboolean meego_media_player_control_get_current_video (MeegoMediaPlayerControl *self, gint *cur_video);
-gboolean meego_media_player_control_get_current_audio (MeegoMediaPlayerControl *self, gint *cur_audio);
-gboolean meego_media_player_control_set_current_video (MeegoMediaPlayerControl *self, gint cur_video);
-gboolean meego_media_player_control_set_current_audio (MeegoMediaPlayerControl *self, gint cur_audio);
-gboolean meego_media_player_control_get_video_num (MeegoMediaPlayerControl *self, gint *video_num);
-gboolean meego_media_player_control_get_audio_num (MeegoMediaPlayerControl *self, gint *audio_num);
-gboolean meego_media_player_control_set_proxy (MeegoMediaPlayerControl *self, GHashTable *params);
-gboolean meego_media_player_control_set_subtitle_uri (MeegoMediaPlayerControl *self, gchar *sub_uri);
-gboolean meego_media_player_control_get_subtitle_num (MeegoMediaPlayerControl *self, gint *sub_num);
-gboolean meego_media_player_control_get_current_subtitle (MeegoMediaPlayerControl *self, gint *cur_sub);
-gboolean meego_media_player_control_set_current_subtitle (MeegoMediaPlayerControl *self, gint cur_sub);
-gboolean meego_media_player_control_set_buffer_depth (MeegoMediaPlayerControl *self, gint format, gint64 buf_val);
-gboolean meego_media_player_control_get_buffer_depth (MeegoMediaPlayerControl *self, gint format, gint64 *buf_val);
-gboolean meego_media_player_control_set_mute (MeegoMediaPlayerControl *self, gint mute);
-gboolean meego_media_player_control_is_mute (MeegoMediaPlayerControl *self, gint *mute);
-gboolean meego_media_player_control_set_scale_mode (MeegoMediaPlayerControl *self, gint scale_mode);
-gboolean meego_media_player_control_get_scale_mode (MeegoMediaPlayerControl *self, gint *scale_mode);
-gboolean meego_media_player_control_suspend (MeegoMediaPlayerControl *self);
-gboolean meego_media_player_control_restore (MeegoMediaPlayerControl *self);
-gboolean meego_media_player_control_get_video_codec (MeegoMediaPlayerControl *self, gint channel, gchar **video_codec);
-gboolean meego_media_player_control_get_audio_codec (MeegoMediaPlayerControl *self, gint channel, gchar **audio_codec);
-gboolean meego_media_player_control_get_video_bitrate (MeegoMediaPlayerControl *self, gint channel, gint *bit_rate);
-gboolean meego_media_player_control_get_audio_bitrate (MeegoMediaPlayerControl *self, gint channel, gint *bit_rate);
-gboolean meego_media_player_control_get_encapsulation(MeegoMediaPlayerControl *self, gchar ** encapsulation);
-gboolean meego_media_player_control_get_audio_samplerate(MeegoMediaPlayerControl *self, gint channel, gint * sample_rate);
-gboolean meego_media_player_control_get_video_framerate(MeegoMediaPlayerControl *self, gint channel,
-                                                        gint * frame_rate_num, gint * frame_rate_denom);
-gboolean meego_media_player_control_get_video_resolution(MeegoMediaPlayerControl *self, gint channel,
-                                                        gint * width, gint * height);
-gboolean meego_media_player_control_get_video_aspect_ratio(MeegoMediaPlayerControl *self,
-                                                    gint channel, gint * ratio_num, gint * ratio_denom);
-gboolean meego_media_player_control_get_protocol_name(MeegoMediaPlayerControl *self, gchar ** prot_name);
-gboolean meego_media_player_control_get_current_uri (MeegoMediaPlayerControl *self, gchar ** uri);
-gboolean meego_media_player_control_get_title(MeegoMediaPlayerControl *self, gchar ** title);
-gboolean meego_media_player_control_get_artist(MeegoMediaPlayerControl *self, gchar ** artist);
-gboolean meego_media_player_control_record (MeegoMediaPlayerControl *self, gboolean to_record, gchar *location);
-gboolean meego_media_player_control_get_pat (MeegoMediaPlayerControl *self, GPtrArray **pat);
-gboolean meego_media_player_control_get_pmt (MeegoMediaPlayerControl *self, 
-                                            guint *program_num, guint *pcr_pid, GPtrArray **stream_info);
-gboolean meego_media_player_control_get_associated_data_channel (MeegoMediaPlayerControl *self, gchar **ip, gint *port);
-
-
-
-/*signal emitter*/
-void meego_media_player_control_emit_initialized (gpointer instance);
-void meego_media_player_control_emit_eof (gpointer instance);
-void meego_media_player_control_emit_error (gpointer instance, guint error_num, gchar *error_des);
-void meego_media_player_control_emit_seeked (gpointer instance);
-void meego_media_player_control_emit_stopped (gpointer instance);
-void meego_media_player_control_emit_request_window (gpointer instance);
-void meego_media_player_control_emit_buffering (gpointer instance);
-void meego_media_player_control_emit_buffered (gpointer instance);
-void meego_media_player_control_emit_player_state_changed (gpointer instance, gint old_state, gint cur_state);
-void meego_media_player_control_emit_target_ready(gpointer instance, GHashTable *infos);
-void meego_media_player_control_emit_video_tag_changed (gpointer instance, gint channel);
-void meego_media_player_control_emit_audio_tag_changed (gpointer instance, gint channel);
-void meego_media_player_control_emit_text_tag_changed (gpointer instance, gint channel);
-void meego_media_player_control_emit_metadata_changed(gpointer instance);
-void meego_media_player_control_emit_suspended (gpointer instance);
-void meego_media_player_control_emit_restored (gpointer instance);
-
-G_END_DECLS
-#endif
--- src/meego-media-player-gstreamer.c
+++ src/meego-media-player-gstreamer.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "umms-debug.h"
-#include "meego-media-player-gstreamer.h"
-#include "meego-media-player-control.h"
-#include "engine-gst.h"
-
-
-G_DEFINE_TYPE (MeegoMediaPlayerGstreamer, meego_media_player_gstreamer, MEEGO_TYPE_MEDIA_PLAYER)
-#define PLAYER_PRIVATE(o) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((o), MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER, MeegoMediaPlayerGstreamerPrivate))
-
-#define GET_PRIVATE(o) ((MeegoMediaPlayerGstreamer *)o)->priv
-
-enum EngineType {
-  MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_INVALID,
-  MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_NORMAL,
-  MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_DVB,
-  N_MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE
-};
-
-struct _MeegoMediaPlayerGstreamerPrivate {
-  enum EngineType engine_type;
-};
-
-//implement load_engine vmethod
-#define TV_PREFIX "dvb:"
-
-MeegoMediaPlayerControl *
-create_engine (gint type)
-{
-  MeegoMediaPlayerControl *engine = NULL;
-
-  if (type == MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_DVB)
-    engine = dvb_player_new();
-  else if (type == MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_NORMAL)
-    engine = engine_gst_new();
-  else 
-    UMMS_DEBUG ("Unknown engine type (%d)", type);
-
-  return engine;
-}
-
-static gboolean meego_media_player_gstreamer_load_engine (MeegoMediaPlayer *player, const char *uri, gboolean *new_engine)
-{
-  gboolean ret;
-  gboolean updated;
-  gint type;
-  MeegoMediaPlayerGstreamerPrivate *priv;
-
-  g_return_val_if_fail (MEEGO_IS_MEDIA_PLAYER_GSTREAMER(player), FALSE);
-  g_return_val_if_fail (uri, FALSE);
-
-  priv = GET_PRIVATE(player);
-  type = (g_str_has_prefix (uri, TV_PREFIX)) ? (MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_DVB): (MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_NORMAL);
-
-  if (!player->player_control) {
-    UMMS_DEBUG ("We have no engine loaded, to load one(type = %d)", type);
-    player->player_control = create_engine (type);
-      updated = TRUE;
-  } else {
-    if (priv->engine_type == type) {
-      UMMS_DEBUG ("Already loaded engine(type = %d), no need to load again", type);
-      updated = FALSE;
-    } else {
-      UMMS_DEBUG ("Changing engine from type(%d) to type(%d)", priv->engine_type, type);
-      g_object_unref (player->player_control);
-      player->player_control = create_engine (type);
-      updated = TRUE;
-    }
-  }
-
-  if (player->player_control) {
-    priv->engine_type = type;
-    *new_engine = updated;
-    ret = TRUE;
-  } else {
-    UMMS_DEBUG ("Loading engine failed");
-    ret = FALSE;
-  }
-
-  return ret;
-}
-
-
-static void
-meego_media_player_gstreamer_get_property (GObject    *object,
-    guint       property_id,
-    GValue     *value,
-    GParamSpec *pspec)
-{
-  switch (property_id) {
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-  }
-}
-
-static void
-meego_media_player_gstreamer_set_property (GObject      *object,
-    guint         property_id,
-    const GValue *value,
-    GParamSpec   *pspec)
-{
-  switch (property_id) {
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-  }
-}
-
-static void
-meego_media_player_gstreamer_dispose (GObject *object)
-{
-  //MeegoMediaPlayerGstreamerPrivate *priv = GET_PRIVATE (object);
-
-  G_OBJECT_CLASS (meego_media_player_gstreamer_parent_class)->dispose (object);
-}
-
-static void
-meego_media_player_gstreamer_finalize (GObject *object)
-{
-  G_OBJECT_CLASS (meego_media_player_gstreamer_parent_class)->finalize (object);
-}
-
-static void
-meego_media_player_gstreamer_class_init (MeegoMediaPlayerGstreamerClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  MeegoMediaPlayerClass *p_class = MEEGO_MEDIA_PLAYER_CLASS (klass);
-
-  g_type_class_add_private (klass, sizeof (MeegoMediaPlayerGstreamerPrivate));
-
-  object_class->get_property = meego_media_player_gstreamer_get_property;
-  object_class->set_property = meego_media_player_gstreamer_set_property;
-  object_class->dispose = meego_media_player_gstreamer_dispose;
-  object_class->finalize = meego_media_player_gstreamer_finalize;
-
-  p_class->load_engine = meego_media_player_gstreamer_load_engine;
-}
-
-static void
-meego_media_player_gstreamer_init (MeegoMediaPlayerGstreamer *self)
-{
-  MeegoMediaPlayerGstreamerPrivate *priv;
-
-  self->priv = PLAYER_PRIVATE (self);
-  priv = self->priv;
-
-  priv->engine_type = MEEGO_MEDIA_PLAYER_GSTREAMER_ENGINE_TYPE_INVALID;
-}
-
-MeegoMediaPlayerGstreamer *
-meego_media_player_gstreamer_new (void)
-{
-  return g_object_new (MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER, NULL);
-}
-
-
-
-
--- src/meego-media-player-gstreamer.h
+++ src/meego-media-player-gstreamer.h
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef _MEEGO_MEDIA_PLAYER_GSTREAMER_H
-#define _MEEGO_MEDIA_PLAYER_GSTREAMER_H
-
-#include <glib-object.h>
-#include <meego-media-player.h>
-
-G_BEGIN_DECLS
-
-#define MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER meego_media_player_gstreamer_get_type()
-
-#define MEEGO_MEDIA_PLAYER_GSTREAMER(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-  MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER, MeegoMediaPlayerGstreamer))
-
-#define MEEGO_MEDIA_PLAYER_GSTREAMER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-  MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER, MeegoMediaPlayerGstreamerClass))
-
-#define MEEGO_IS_MEDIA_PLAYER_GSTREAMER(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-  MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER))
-
-#define MEEGO_IS_MEDIA_PLAYER_GSTREAMER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-  MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER))
-
-#define MEEGO_MEDIA_PLAYER_GSTREAMER_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-  MEEGO_TYPE_MEDIA_PLAYER_GSTREAMER, MeegoMediaPlayerGstreamerClass))
-
-typedef struct _MeegoMediaPlayerGstreamer MeegoMediaPlayerGstreamer;
-typedef struct _MeegoMediaPlayerGstreamerClass MeegoMediaPlayerGstreamerClass;
-typedef struct _MeegoMediaPlayerGstreamerPrivate MeegoMediaPlayerGstreamerPrivate;
-
-struct _MeegoMediaPlayerGstreamer
-{
-  MeegoMediaPlayer parent;
-
-  MeegoMediaPlayerGstreamerPrivate *priv;
-};
-
-
-struct _MeegoMediaPlayerGstreamerClass
-{
-  MeegoMediaPlayerClass parent_class;
-
-};
-
-GType meego_media_player_gstreamer_get_type (void) G_GNUC_CONST;
-
-MeegoMediaPlayerGstreamer *meego_media_player_gstreamer_new (void);
-
-G_END_DECLS
-
-#endif /* _MEEGO_MEDIA_PLAYER_GSTREAMER_H */
--- src/meego-media-player.c
+++ src/meego-media-player.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
-#include <dbus/dbus-glib.h>
-
-#include "umms-debug.h"
-#include "umms-common.h"
-#include "umms-error.h"
-#include "umms-marshals.h"
-#include "meego-media-player.h"
-#include "meego-media-player-control.h"
-
-G_DEFINE_TYPE (MeegoMediaPlayer, meego_media_player, G_TYPE_OBJECT)
-
-#define PLAYER_PRIVATE(o) \
-        (G_TYPE_INSTANCE_GET_PRIVATE ((o), MEEGO_TYPE_MEDIA_PLAYER, MeegoMediaPlayerPrivate))
-
-#define GET_PRIVATE(o) ((MeegoMediaPlayer *)o)->priv
-
-#define GET_CONTROL_IFACE(meego_media_player) (((MeegoMediaPlayer *)(meego_media_player))->player_control)
-
-#define CHECK_ENGINE(engine, ret_val, e) \
-  do {\
-    if (engine == NULL) {\
-      g_return_val_if_fail (e == NULL || *e == NULL, ret_val);\
-      if (e != NULL) {\
-        g_set_error (e, UMMS_ENGINE_ERROR, UMMS_ENGINE_ERROR_NOT_LOADED, \
-                     "Pipeline engine not loaded, possible reason is SetUri failed or not be invoked.");\
-      } \
-      return ret_val;\
-    }\
-  }while(0)
-
-#define   DEFAULT_SCALE_MODE  ScaleModeKeepAspectRatio
-#define   DEFAULT_VOLUME 50
-#define   DEFAULT_MUTE   FALSE
-#define   DEFAULT_X      0
-#define   DEFAULT_Y      0
-#define   DEFAULT_WIDTH  720
-#define   DEFAULT_HIGHT  576
-
-
-enum {
-  PROP_0,
-  PROP_NAME,
-  PROP_ATTENDED,
-  PROP_LAST
-};
-
-enum {
-  SIGNAL_MEDIA_PLAYER_Initialized,
-  SIGNAL_MEDIA_PLAYER_Eof,
-  SIGNAL_MEDIA_PLAYER_Error,
-  SIGNAL_MEDIA_PLAYER_Buffering,
-  SIGNAL_MEDIA_PLAYER_Buffered,
-  SIGNAL_MEDIA_PLAYER_RequestWindow,
-  SIGNAL_MEDIA_PLAYER_Seeked,
-  SIGNAL_MEDIA_PLAYER_Stopped,
-  SIGNAL_MEDIA_PLAYER_PlayerStateChanged,
-  SIGNAL_MEDIA_PLAYER_NeedReply,
-  SIGNAL_MEDIA_PLAYER_ClientNoReply,
-  SIGNAL_MEDIA_PLAYER_TargetReady,
-  SIGNAL_MEDIA_PLAYER_Suspended,
-  SIGNAL_MEDIA_PLAYER_Restored,
-  SIGNAL_MEDIA_PLAYER_NoResource,
-  SIGNAL_MEDIA_PLAYER_VideoTagChanged,
-  SIGNAL_MEDIA_PLAYER_AudioTagChanged,
-  SIGNAL_MEDIA_PLAYER_TextTagChanged,
-  SIGNAL_MEDIA_PLAYER_MetadataChanged,
-  N_MEDIA_PLAYER_SIGNALS
-};
-
-static guint media_player_signals[N_MEDIA_PLAYER_SIGNALS] = {0};
-
-struct _MeegoMediaPlayerPrivate {
-  gchar    *name;
-  gboolean attended;
-
-  /*Parameters need to be cached due to the unavailable of underlying player.*/
-  gchar    *uri;
-  gchar    *sub_uri;
-
-  gint     volume;
-  gint     mute;
-  gint     scale_mode;
-  gint     x;
-  gint     y;
-  guint    w;
-  guint    h;
-  gint        target_type;
-  GHashTable *target_params;
-  GHashTable *http_proxy_params;
-
-  //For client existence checking.
-  guint    no_reply_time;
-  guint    timeout_id;
-
-  //Media player "snapshot", for suspend/restore operation.
-  gint64   position;
-
-  };
-
-static void
-connect_signals(MeegoMediaPlayer *player, MeegoMediaPlayerControl *control);
-
-static void
-request_window_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_RequestWindow], 0);
-
-}
-
-static void
-eof_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Eof], 0);
-}
-static void
-error_cb (MeegoMediaPlayerControl *iface, guint error_num, gchar *error_des, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Error], 0, error_num, error_des);
-}
-
-static void
-buffering_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Buffering], 0);
-}
-
-static void
-buffered_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Buffered], 0);
-}
-
-static void
-player_state_changed_cb (MeegoMediaPlayerControl *iface, gint old_state, gint new_state, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_PlayerStateChanged], 0, old_state, new_state);
-}
-
-static void
-target_ready_cb (MeegoMediaPlayerControl *iface, GHashTable *infos, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_TargetReady], 0, infos);
-}
-
-static void
-seeked_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Seeked], 0);
-}
-static void
-stopped_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Stopped], 0);
-}
-
-static void
-suspended_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Suspended], 0);
-}
-
-static void
-restored_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Restored], 0);
-}
-
-static void
-video_tag_changed_cb (MeegoMediaPlayerControl *iface, gint channel, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_VideoTagChanged], 0, channel);
-}
-
-static void
-audio_tag_changed_cb (MeegoMediaPlayerControl *iface, gint channel, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_AudioTagChanged], 0, channel);
-}
-
-static void
-text_tag_changed_cb (MeegoMediaPlayerControl *iface, gint channel, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_TextTagChanged], 0, channel);
-}
-
-static void
-metadata_changed_cb (MeegoMediaPlayerControl *iface, MeegoMediaPlayer *player)
-{
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_MetadataChanged], 0);
-}
-
-static gboolean
-client_existence_check (MeegoMediaPlayer *player)
-{
-  gboolean ret = TRUE;
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-#define CHECK_INTERVAL (500)
-#define CLI_REPLY_TIMEOUT (2500)
-
-  if (priv->no_reply_time > CLI_REPLY_TIMEOUT) {
-    UMMS_DEBUG ("Client didn't response for '%u' ms, stop this AV execution", priv->no_reply_time);
-    g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_ClientNoReply], 0);
-    ret = FALSE;
-  } else {
-    g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_NeedReply], 0);
-    priv->no_reply_time  += CHECK_INTERVAL;
-  }
-  return ret;
-}
-
-gboolean
-meego_media_player_reply (MeegoMediaPlayer *player, GError **err)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-  priv->no_reply_time = 0;
-
-  return TRUE;
-}
-
-/* Create inner player engine which can handle this uri, and set all the cached properties*/
-gboolean meego_media_player_load_engine (MeegoMediaPlayer *player, const gchar *uri, gboolean *new_engine)
-{
-  MeegoMediaPlayerClass *kclass = MEEGO_MEDIA_PLAYER_GET_CLASS (player);
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  if (!kclass->load_engine) {
-    UMMS_DEBUG ("virtual method \"load_engine\" not implemented");
-    return FALSE;
-  }
-
-  if (!kclass->load_engine (player, uri, new_engine)) {
-    UMMS_DEBUG ("loading pipeline engine failed");
-    return FALSE;
-  }
-
-  if (*new_engine) {
-    connect_signals (player, player->player_control);
-  }
-
-  /* Set all the cached property. */
-  meego_media_player_control_set_uri (player->player_control, priv->uri);
-  meego_media_player_control_set_volume (player->player_control, priv->volume);
-  meego_media_player_control_set_mute (player->player_control, priv->mute);
-  meego_media_player_control_set_scale_mode (player->player_control, priv->scale_mode);
-  if (priv->http_proxy_params)
-    meego_media_player_control_set_proxy (player->player_control, priv->http_proxy_params);
-  if (priv->target_params)
-    meego_media_player_control_set_target (player->player_control, priv->target_type, priv->target_params);
-  if (priv->sub_uri)
-    meego_media_player_control_set_subtitle_uri (GET_CONTROL_IFACE (player), priv->sub_uri);
-
-  UMMS_DEBUG ("new: %d", *new_engine);
-  g_signal_emit (player, media_player_signals[SIGNAL_MEDIA_PLAYER_Initialized], 0);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_uri (MeegoMediaPlayer *player,
-    const gchar           *uri,
-    GError **err)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  if (!uri || uri[0] == '\0') {
-    UMMS_DEBUG ("Invalid URI");
-    g_set_error (err, UMMS_GENERIC_ERROR, UMMS_GENERIC_ERROR_INVALID_PARAM, "Invalid URI");
-    return FALSE;
-  }
-
-  if (priv->uri) {
-    meego_media_player_stop (player, NULL);
-    g_free (priv->uri);
-  }
-
-  priv->uri = g_strdup (uri);
-  UMMS_DEBUG ("URI: %s", uri);
-  return TRUE;
-}
-
-//For convenience's sake, we don't cache the target info if player backend is not ready.
-gboolean
-meego_media_player_set_target (MeegoMediaPlayer *player, gint type, GHashTable *params,
-    GError **err)
-{
-  gboolean ret = TRUE;
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  if (player->player_control) {
-    ret = meego_media_player_control_set_target (GET_CONTROL_IFACE (player), type, params);
-  } else {
-    priv->target_type = type;
-    if (priv->target_params)
-      g_hash_table_unref (priv->target_params);
-    priv->target_params = g_hash_table_ref (params);
-  }
-
-  return ret;
-}
-
-gboolean meego_media_player_activate (MeegoMediaPlayer *player, PlayerState state)
-{
-
-  gboolean ret = TRUE;
-  gboolean new_engine = FALSE;
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  if (!priv->uri) {
-    UMMS_DEBUG ("No URI specified");
-    return FALSE;
-  }
-
-  if (!player->player_control) {
-    if (!meego_media_player_load_engine (player, priv->uri, &new_engine)) {
-      return FALSE;
-    }
-  }
-
-  switch (state) {
-    case PlayerStatePaused:
-      ret = meego_media_player_control_pause (player->player_control);
-      break;
-    case PlayerStatePlaying:
-      ret = meego_media_player_control_play (player->player_control);
-      break;
-    default:
-      UMMS_DEBUG ("Invalid target state: %d", state);
-      ret = FALSE;
-      break;
-  }
-
-  UMMS_DEBUG ("setting engine to state: %d ", state);
-  return ret;
-}
-
-gboolean
-meego_media_player_play (MeegoMediaPlayer *player,
-    GError **err)
-{
-  return meego_media_player_activate (player, PlayerStatePlaying);
-}
-
-gboolean
-meego_media_player_pause(MeegoMediaPlayer *player,
-    GError **err)
-{
-  return meego_media_player_activate (player, PlayerStatePaused);
-}
-
-gboolean
-meego_media_player_stop (MeegoMediaPlayer *player,
-    GError **err)
-{
-  if (player->player_control) {
-    meego_media_player_control_stop (player->player_control);
-    g_object_unref (player->player_control);
-    player->player_control = NULL;
-  }
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_window_id (MeegoMediaPlayer *player,
-    gdouble window_id,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_set_window_id (GET_CONTROL_IFACE (player), window_id);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_video_size(MeegoMediaPlayer *player,
-    guint in_x,
-    guint in_y,
-    guint in_w,
-    guint in_h,
-    GError **err)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-  MeegoMediaPlayerControl *player_control = GET_CONTROL_IFACE (player);
-
-  UMMS_DEBUG ("rectangle=\"%u,%u,%u,%u\"", in_x, in_y, in_w, in_h );
-
-  if (player_control) {
-    meego_media_player_control_set_video_size (GET_CONTROL_IFACE (player), in_x, in_y, in_w, in_h);
-  } else {
-    UMMS_DEBUG ("Cache the video size parameters since pipe engine has not been loaded");
-    priv->x = in_x;
-    priv->y = in_y;
-    priv->w = in_w;
-    priv->h = in_h;
-  }
-  return TRUE;
-}
-
-
-gboolean
-meego_media_player_get_video_size(MeegoMediaPlayer *player, guint *w, guint *h,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_size (GET_CONTROL_IFACE (player), w, h);
-  return TRUE;
-}
-
-
-gboolean
-meego_media_player_is_seekable(MeegoMediaPlayer *player, gboolean *is_seekable, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_is_seekable (GET_CONTROL_IFACE (player), is_seekable);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_position(MeegoMediaPlayer *player,
-    gint64                 in_pos,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_set_position (GET_CONTROL_IFACE (player), in_pos);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_position(MeegoMediaPlayer *player, gint64 *pos,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  return meego_media_player_control_get_position (GET_CONTROL_IFACE (player), pos);
-}
-
-gboolean
-meego_media_player_set_playback_rate (MeegoMediaPlayer *player,
-    gdouble          in_rate,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  return meego_media_player_control_set_playback_rate (GET_CONTROL_IFACE (player), in_rate);
-}
-
-gboolean
-meego_media_player_get_playback_rate (MeegoMediaPlayer *player,
-    gdouble *rate,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_playback_rate (GET_CONTROL_IFACE (player), rate);
-  UMMS_DEBUG ("current rate = %f",  *rate);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_volume (MeegoMediaPlayer *player,
-    gint                  volume,
-    GError **err)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-  MeegoMediaPlayerControl *player_control = GET_CONTROL_IFACE (player);
-
-  UMMS_DEBUG ("set volume to %d",  volume);
-
-  if (player_control) {
-    meego_media_player_control_set_volume (player_control, volume);
-  } else {
-    UMMS_DEBUG ("MediaPlayer not ready, cache the volume.");
-    priv->volume = volume;
-  }
-
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_volume (MeegoMediaPlayer *player,
-    gint *vol,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_volume (GET_CONTROL_IFACE (player), vol);
-  UMMS_DEBUG ("current volume= %d",  *vol);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_media_size_time (MeegoMediaPlayer *player,
-    gint64 *duration,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_media_size_time(GET_CONTROL_IFACE (player), duration);
-  UMMS_DEBUG ("duration = %lld",  *duration);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_media_size_bytes (MeegoMediaPlayer *player,
-    gint64 *size_bytes,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_media_size_bytes (GET_CONTROL_IFACE (player), size_bytes);
-  UMMS_DEBUG ("media size = %lld",  *size_bytes);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_has_video (MeegoMediaPlayer *player,
-    gboolean *has_video,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_has_video (GET_CONTROL_IFACE (player), has_video);
-  UMMS_DEBUG ("has_video = %d",  *has_video);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_has_audio (MeegoMediaPlayer *player,
-    gboolean *has_audio,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_has_audio (GET_CONTROL_IFACE (player), has_audio);
-  UMMS_DEBUG ("has_audio= %d",  *has_audio);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_support_fullscreen (MeegoMediaPlayer *player,
-    gboolean *support_fullscreen,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_support_fullscreen (GET_CONTROL_IFACE (player), support_fullscreen);
-  UMMS_DEBUG ("support_fullscreen = %d",  *support_fullscreen);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_is_streaming (MeegoMediaPlayer *player,
-    gboolean *is_streaming,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_is_streaming (GET_CONTROL_IFACE (player), is_streaming);
-  UMMS_DEBUG ("is_streaming = %d",  *is_streaming);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_player_state(MeegoMediaPlayer *player, gint *state, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_player_state (GET_CONTROL_IFACE (player), state);
-  UMMS_DEBUG ("player state = %d",  *state);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_buffered_bytes (MeegoMediaPlayer *player, gint64 *bytes, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_buffered_bytes (GET_CONTROL_IFACE (player), bytes);
-  UMMS_DEBUG ("buffered bytes = %lld",  *bytes);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_buffered_time (MeegoMediaPlayer *player, gint64 *size_time, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_buffered_time (GET_CONTROL_IFACE (player), size_time);
-  UMMS_DEBUG ("buffered time = %lld",  *size_time);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_current_video (MeegoMediaPlayer *player, gint *cur_video, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_current_video(GET_CONTROL_IFACE (player), cur_video);
-  UMMS_DEBUG ("get the current video is %d", *cur_video);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_current_audio (MeegoMediaPlayer *player, gint *cur_audio, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_current_audio(GET_CONTROL_IFACE (player), cur_audio);
-  UMMS_DEBUG ("get the current audio is %d", *cur_audio);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_current_video (MeegoMediaPlayer *player, gint cur_video, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_set_current_video(GET_CONTROL_IFACE (player), cur_video);
-  UMMS_DEBUG ("set the current video to %d", cur_video);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_current_audio (MeegoMediaPlayer *player, gint cur_audio, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_set_current_audio(GET_CONTROL_IFACE (player), cur_audio);
-  UMMS_DEBUG ("set the current audio to %d", cur_audio);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_video_num (MeegoMediaPlayer *player, gint *video_num, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_num(GET_CONTROL_IFACE (player), video_num);
-  UMMS_DEBUG ("the total video number is %d", *video_num);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_audio_num (MeegoMediaPlayer *player, gint *audio_num, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_audio_num(GET_CONTROL_IFACE (player), audio_num);
-  UMMS_DEBUG ("the total audio number is %d", *audio_num);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_proxy (MeegoMediaPlayer *player,
-    GHashTable *params,
-    GError **err)
-{
-  gboolean ret = TRUE;
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  if (player->player_control) {
-    meego_media_player_control_set_proxy (GET_CONTROL_IFACE (player), params);
-  } else {
-    if (priv->http_proxy_params)
-      g_hash_table_unref (priv->http_proxy_params);
-    priv->http_proxy_params = g_hash_table_ref (params);
-  }
-
-  return ret;
-}
-
-//Stop player, so that all resources occupied will be released.
-gboolean
-meego_media_player_suspend(MeegoMediaPlayer *player,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_suspend (GET_CONTROL_IFACE (player));
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_subtitle_uri (MeegoMediaPlayer *player, gchar *sub_uri, GError **err)
-{
-  gboolean ret = TRUE;
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  UMMS_DEBUG ("Want to set the suburi to %s", sub_uri);
-  if (player->player_control) {
-    ret = meego_media_player_control_set_subtitle_uri (GET_CONTROL_IFACE (player), sub_uri);
-  } else {
-    RESET_STR (priv->sub_uri);
-    UMMS_DEBUG ("cache the suburi %s", sub_uri);
-    priv->sub_uri = g_strdup (sub_uri);
-  }
-
-  return ret;
-}
-
-gboolean
-meego_media_player_restore (MeegoMediaPlayer *player,
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_restore (GET_CONTROL_IFACE (player));
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_subtitle_num (MeegoMediaPlayer *player, gint *sub_num, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_subtitle_num(GET_CONTROL_IFACE (player), sub_num);
-  UMMS_DEBUG ("the total subtitle number is %d", *sub_num);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_current_subtitle (MeegoMediaPlayer *player, gint *cur_sub, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_current_subtitle(GET_CONTROL_IFACE (player), cur_sub);
-  UMMS_DEBUG ("get the current subtitle is %d", *cur_sub);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_current_subtitle (MeegoMediaPlayer *player, gint cur_sub, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_set_current_subtitle(GET_CONTROL_IFACE (player), cur_sub);
-  UMMS_DEBUG ("set the current subtitle to %d", cur_sub);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_buffer_depth (MeegoMediaPlayer *player, gint format, gint64 buf_val, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_set_buffer_depth(GET_CONTROL_IFACE (player), format, buf_val);
-  UMMS_DEBUG ("set the format to %d, buffer to %lld", format, buf_val);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_buffer_depth (MeegoMediaPlayer *player, gint format, gint64 *buf_val, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_buffer_depth(GET_CONTROL_IFACE (player), format, buf_val);
-  UMMS_DEBUG ("set the format to %d, buffer to %lld", format, *buf_val);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_mute (MeegoMediaPlayer *player, gint mute, GError **err)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-  MeegoMediaPlayerControl *player_control = GET_CONTROL_IFACE (player);
-
-  UMMS_DEBUG ("will set mute to %d", mute);
-
-  if (player_control) {
-    meego_media_player_control_set_mute(GET_CONTROL_IFACE (player), mute);
-  } else {
-    UMMS_DEBUG ("MediaPlayer not ready, cache the mute.");
-    priv->mute = mute;
-  }
-  return TRUE;
-}
-
-gboolean
-meego_media_player_is_mute (MeegoMediaPlayer *player, gint *mute, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-
-  meego_media_player_control_is_mute (GET_CONTROL_IFACE (player), mute);
-  UMMS_DEBUG ("current mute is %d", *mute);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_set_scale_mode (MeegoMediaPlayer *player, gint scale_mode, GError **err)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-  MeegoMediaPlayerControl *player_control = GET_CONTROL_IFACE (player);
-
-  UMMS_DEBUG ("will set scale mode to %d", scale_mode);
-
-  if (player_control) {
-    meego_media_player_control_set_scale_mode (GET_CONTROL_IFACE (player), scale_mode);
-  } else {
-    UMMS_DEBUG ("MediaPlayer not ready, cache the scale mode.");
-    priv->scale_mode = scale_mode;
-  }
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_scale_mode (MeegoMediaPlayer *player, gint *scale_mode, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_scale_mode(GET_CONTROL_IFACE (player), scale_mode);
-  UMMS_DEBUG ("get the current scale mode is %d", *scale_mode);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_video_codec (MeegoMediaPlayer *player, gint channel, gchar **video_codec, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_codec(GET_CONTROL_IFACE (player), channel, video_codec);
-  UMMS_DEBUG ("We get the video codec: %s", *video_codec);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_audio_codec (MeegoMediaPlayer *player, gint channel, gchar **audio_codec, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_audio_codec(GET_CONTROL_IFACE (player), channel, audio_codec);
-  UMMS_DEBUG ("We get the audio codec: %s", *audio_codec);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_video_bitrate (MeegoMediaPlayer *player, gint channel, gint *bit_rate, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_bitrate(GET_CONTROL_IFACE (player), channel, bit_rate);
-  UMMS_DEBUG ("We get the video bitrate: %d", *bit_rate);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_audio_bitrate (MeegoMediaPlayer *player, gint channel, gint *bit_rate, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_audio_bitrate(GET_CONTROL_IFACE (player), channel, bit_rate);
-  UMMS_DEBUG ("We get the audio:%d bitrate: %d", channel, *bit_rate);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_encapsulation (MeegoMediaPlayer *player, gchar **encapsulation, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_encapsulation(GET_CONTROL_IFACE (player), encapsulation);
-  UMMS_DEBUG ("We get the encapsulation: %s", *encapsulation);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_audio_samplerate (MeegoMediaPlayer *player, gint channel, gint *sample_rate, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_audio_samplerate(GET_CONTROL_IFACE (player), channel, sample_rate);
-  UMMS_DEBUG ("We get the sample rate: %d", *sample_rate);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_video_framerate (MeegoMediaPlayer *player, gint channel,
-    gint * frame_rate_num, gint * frame_rate_denom, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_framerate(GET_CONTROL_IFACE (player),
-      channel, frame_rate_num, frame_rate_denom);
-  UMMS_DEBUG ("We get the sample rate: %f", *(gdouble*)frame_rate_num / *(gdouble*)frame_rate_denom);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_video_resolution (MeegoMediaPlayer *player, gint channel,
-    gint * width, gint * height, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_resolution(GET_CONTROL_IFACE (player), channel, width, height);
-  UMMS_DEBUG ("We get the video resolution: %d X %d", *width, *height);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_video_aspect_ratio (MeegoMediaPlayer *player, gint channel,
-    gint * ratio_num, gint * ratio_denom, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_video_aspect_ratio(GET_CONTROL_IFACE (player),
-      channel, ratio_num, ratio_denom);
-  UMMS_DEBUG ("We get the video aspect ratio: %d : %d", *ratio_num, *ratio_denom);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_protocol_name (MeegoMediaPlayer *player, gchar **protocol_name, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_protocol_name(GET_CONTROL_IFACE (player), protocol_name);
-  UMMS_DEBUG ("We get the protocol name: %s", *protocol_name);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_current_uri (MeegoMediaPlayer *player, gchar **uri, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_current_uri(GET_CONTROL_IFACE (player), uri);
-  UMMS_DEBUG ("We get the uri: %s", *uri);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_title (MeegoMediaPlayer *player, gchar **title, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_title(GET_CONTROL_IFACE (player), title);
-  return TRUE;
-}
-
-gboolean
-meego_media_player_get_artist (MeegoMediaPlayer *player, gchar **artist, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_artist(GET_CONTROL_IFACE (player), artist);
-  return TRUE;
-}
-static void
-meego_media_player_get_property (GObject    *object,
-    guint       property_id,
-    GValue     *value,
-    GParamSpec *pspec)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (object);
-
-  switch (property_id) {
-    case PROP_NAME:
-      g_value_set_string (value, priv->name);
-      break;
-    case PROP_ATTENDED:
-      g_value_set_boolean (value, priv->attended);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-  }
-}
-
-static void
-meego_media_player_set_property (GObject      *object,
-    guint         property_id,
-    const GValue *value,
-    GParamSpec   *pspec)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (object);
-  const gchar *tmp;
-
-  switch (property_id) {
-    case PROP_NAME:
-      tmp = g_value_get_string (value);
-      UMMS_DEBUG ("name= %s'", tmp);
-      priv->name = g_value_dup_string (value);
-      break;
-    case PROP_ATTENDED:
-      priv->attended = g_value_get_boolean (value);
-      UMMS_DEBUG ("attended=%d", priv->attended);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-  }
-}
-
-static void
-meego_media_player_dispose (GObject *object)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (object);
-  MeegoMediaPlayerControl *player_control = GET_CONTROL_IFACE (object);
-
-  if (player_control) {
-    meego_media_player_control_stop (player_control);
-    g_object_unref (player_control);
-  }
-
-  if (priv->http_proxy_params)
-    g_hash_table_unref (priv->http_proxy_params);
-
-  if (priv->target_params)
-    g_hash_table_unref (priv->target_params);
-
-  RESET_STR (priv->uri);
-  RESET_STR (priv->sub_uri);
-  RESET_STR (priv->name);
-
-  if (priv->attended && priv->timeout_id > 0) {
-    g_source_remove (priv->timeout_id);
-  }
-
-  G_OBJECT_CLASS (meego_media_player_parent_class)->dispose (object);
-}
-
-static void
-meego_media_player_finalize (GObject *object)
-{
-  G_OBJECT_CLASS (meego_media_player_parent_class)->finalize (object);
-}
-
-static void
-meego_media_player_constructed (GObject *player)
-{
-  MeegoMediaPlayerPrivate *priv;
-
-  priv = GET_PRIVATE (player);
-
-  UMMS_DEBUG ("enter");
-  //For client existence checking
-  if (priv->attended) {
-    UMMS_DEBUG ("Attended execution, add client checking");
-    priv->timeout_id = g_timeout_add (CHECK_INTERVAL, (GSourceFunc)client_existence_check, player);
-  }
-}
-
-static void
-meego_media_player_class_init (MeegoMediaPlayerClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  g_type_class_add_private (klass, sizeof (MeegoMediaPlayerPrivate));
-
-  object_class->get_property = meego_media_player_get_property;
-  object_class->set_property = meego_media_player_set_property;
-  object_class->constructed = meego_media_player_constructed;
-  object_class->dispose = meego_media_player_dispose;
-  object_class->finalize = meego_media_player_finalize;
-
-  g_object_class_install_property (object_class, PROP_NAME,
-      g_param_spec_string ("name", "Name", "Name of the mediaplayer",
-          NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-  g_object_class_install_property (object_class, PROP_ATTENDED,
-      g_param_spec_boolean ("attended", "Attended", "Flag to indicate whether this execution is attended",
-          TRUE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Initialized] =
-    g_signal_new ("initialized",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Eof] =
-    g_signal_new ("eof",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Error] =
-    g_signal_new ("error",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  umms_marshal_VOID__UINT_STRING,
-                  G_TYPE_NONE,
-                  2,
-                  G_TYPE_UINT,
-                  G_TYPE_STRING);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Buffering] =
-    g_signal_new ("buffering",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Buffered] =
-    g_signal_new ("buffered",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_RequestWindow] =
-    g_signal_new ("request-window",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Seeked] =
-    g_signal_new ("seeked",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Stopped] =
-    g_signal_new ("stopped",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_PlayerStateChanged] =
-    g_signal_new ("player-state-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  umms_marshal_VOID__INT_INT,
-                  G_TYPE_NONE,
-                  2,
-                  G_TYPE_INT,
-                  G_TYPE_INT);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_NeedReply] =
-    g_signal_new ("need-reply",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_ClientNoReply] =
-    g_signal_new ("client-no-reply",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_TargetReady] =
-    g_signal_new ("target-ready",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__BOXED,
-                  G_TYPE_NONE,
-                  1, dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Suspended] =
-    g_signal_new ("suspended",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_Restored] =
-    g_signal_new ("restored",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_NoResource] =
-    g_signal_new ("no-resource",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_VideoTagChanged] =
-    g_signal_new ("video-tag-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__INT,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_INT);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_AudioTagChanged] =
-    g_signal_new ("audio-tag-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__INT,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_INT);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_TextTagChanged] =
-    g_signal_new ("text-tag-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__INT,
-                  G_TYPE_NONE,
-                  1,
-                  G_TYPE_INT);
-
-  media_player_signals[SIGNAL_MEDIA_PLAYER_MetadataChanged] =
-    g_signal_new ("metadata-changed",
-                  G_OBJECT_CLASS_TYPE (klass),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-                  0,
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE,
-                  0);
-}
-
-static void
-meego_media_player_set_default_params (MeegoMediaPlayer *player)
-{
-  MeegoMediaPlayerPrivate *priv = GET_PRIVATE (player);
-
-  priv->scale_mode = DEFAULT_SCALE_MODE;
-  priv->volume = DEFAULT_VOLUME;
-  priv->mute   = DEFAULT_MUTE;
-  priv->x = DEFAULT_X;
-  priv->y = DEFAULT_Y;
-  priv->w = DEFAULT_WIDTH;
-  priv->h = DEFAULT_HIGHT;
-}
-
-static void
-meego_media_player_init (MeegoMediaPlayer *player)
-{
-  MeegoMediaPlayerPrivate *priv;
-  priv = player->priv = PLAYER_PRIVATE (player);
-
-  player->player_control = NULL;
-  priv->uri     = NULL;
-  priv->sub_uri = NULL;
-  priv->target_params = NULL;
-  meego_media_player_set_default_params (player);
-}
-
-MeegoMediaPlayer *
-meego_media_player_new (void)
-{
-  return g_object_new (MEEGO_TYPE_MEDIA_PLAYER, NULL);
-}
-
-static void
-connect_signals(MeegoMediaPlayer *player, MeegoMediaPlayerControl *control)
-{
-  g_signal_connect_object (control, "request-window",
-      G_CALLBACK (request_window_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "eof",
-      G_CALLBACK (eof_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "error",
-      G_CALLBACK (error_cb),
-      player,
-      0);
-
-  g_signal_connect_object (control, "seeked",
-      G_CALLBACK (seeked_cb),
-      player,
-      0);
-
-  g_signal_connect_object (control, "stopped",
-      G_CALLBACK (stopped_cb),
-      player,
-      0);
-
-  g_signal_connect_object (control, "buffering",
-      G_CALLBACK (buffering_cb),
-      player,
-      0);
-
-  g_signal_connect_object (control, "buffered",
-      G_CALLBACK (buffered_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "player-state-changed",
-      G_CALLBACK (player_state_changed_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "target-ready",
-      G_CALLBACK (target_ready_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "suspended",
-      G_CALLBACK (suspended_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "restored",
-      G_CALLBACK (restored_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "video-tag-changed",
-      G_CALLBACK (video_tag_changed_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "audio-tag-changed",
-      G_CALLBACK (audio_tag_changed_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "text-tag-changed",
-      G_CALLBACK (text_tag_changed_cb),
-      player,
-      0);
-  g_signal_connect_object (control, "metadata-changed",
-      G_CALLBACK (metadata_changed_cb),
-      player,
-      0);
-}
-
-gboolean 
-meego_media_player_record (MeegoMediaPlayer *player, gboolean to_record, gchar *location, GError **err)
-{
-  gboolean ret;
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  ret = meego_media_player_control_record (GET_CONTROL_IFACE (player), to_record, location);
-  if (!ret) {
-    g_set_error (err, UMMS_ENGINE_ERROR, UMMS_ENGINE_ERROR_FAILED, "Record failed");
-  }
-  return ret;
-}
-
-gboolean 
-meego_media_player_get_pat (MeegoMediaPlayer *player, GPtrArray **pat, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_pat (GET_CONTROL_IFACE (player), pat);
-  return TRUE;
-}
-
-gboolean 
-meego_media_player_get_pmt (MeegoMediaPlayer *player, guint *program_num, guint *pcr_pid, GPtrArray **stream_info, 
-    GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_pmt (GET_CONTROL_IFACE (player), program_num, pcr_pid, stream_info);
-  return TRUE;
-}
-
-gboolean 
-meego_media_player_get_associated_data_channel (MeegoMediaPlayer *player, gchar **ip, gint *port, GError **err)
-{
-  CHECK_ENGINE(GET_CONTROL_IFACE (player), FALSE, err);
-  meego_media_player_control_get_associated_data_channel (GET_CONTROL_IFACE (player), ip, port);
-  return TRUE;
-}
--- src/meego-media-player.h
+++ src/meego-media-player.h
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef _MEEGO_MEDIA_PLAYER_H
-#define _MEEGO_MEDIA_PLAYER_H
-
-#include <glib-object.h>
-#include "meego-media-player-control.h"
-
-G_BEGIN_DECLS
-
-#define MEEGO_TYPE_MEDIA_PLAYER meego_media_player_get_type()
-
-#define MEEGO_MEDIA_PLAYER(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-  MEEGO_TYPE_MEDIA_PLAYER, MeegoMediaPlayer))
-
-#define MEEGO_MEDIA_PLAYER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-  MEEGO_TYPE_MEDIA_PLAYER, MeegoMediaPlayerClass))
-
-#define MEEGO_IS_MEDIA_PLAYER(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-  MEEGO_TYPE_MEDIA_PLAYER))
-
-#define MEEGO_IS_MEDIA_PLAYER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-  MEEGO_TYPE_MEDIA_PLAYER))
-
-#define MEEGO_MEDIA_PLAYER_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-  MEEGO_TYPE_MEDIA_PLAYER, MeegoMediaPlayerClass))
-
-typedef struct _MeegoMediaPlayer MeegoMediaPlayer;
-typedef struct _MeegoMediaPlayerClass MeegoMediaPlayerClass;
-typedef struct _MeegoMediaPlayerPrivate MeegoMediaPlayerPrivate;
-
-struct _MeegoMediaPlayer
-{
-  GObject parent;
-  MeegoMediaPlayerControl *player_control;
-
-  MeegoMediaPlayerPrivate *priv;
-};
-
-
-struct _MeegoMediaPlayerClass
-{
-    GObjectClass parent_class;
-
-    /*
-     *
-     * self:            A MeegoMediaPlayer
-     * uri:             Uri to play
-     * new_engine[out]: TRUE if loaded a new engine and destroyed old engine
-     *                  FALSE if not
-     *
-     * Returns:         TRUE if successful
-     *                  FALSE if not
-     *
-     * Load engine according to uri prefix which indicates the source type, and store it in MeegoMediaPlayer::player_control.
-     * Subclass should implement this vmethod to customize the procedure of backend engine loading.
-     *          
-     */
-    gboolean (*load_engine) (MeegoMediaPlayer *self, const char *uri, gboolean *new_engine);
-
-};
-
-GType meego_media_player_get_type (void) G_GNUC_CONST;
-
-MeegoMediaPlayer *meego_media_player_new (void);
-
-gboolean meego_media_player_set_uri (MeegoMediaPlayer *self, const gchar *uri, GError **error);
-gboolean meego_media_player_set_target (MeegoMediaPlayer *self, gint type, GHashTable *params, GError **error);
-gboolean meego_media_player_play(MeegoMediaPlayer *self, GError **error);
-gboolean meego_media_player_pause(MeegoMediaPlayer *self, GError **error);
-gboolean meego_media_player_stop(MeegoMediaPlayer *self, GError **error);
-gboolean meego_media_player_set_position(MeegoMediaPlayer *self, gint64 pos, GError **error);
-gboolean meego_media_player_get_position(MeegoMediaPlayer *self, gint64 *pos, GError **error);
-gboolean meego_media_player_set_playback_rate(MeegoMediaPlayer *self, gdouble rate, GError **error);
-gboolean meego_media_player_get_playback_rate(MeegoMediaPlayer *self, gdouble *rate, GError **error);
-gboolean meego_media_player_set_volume(MeegoMediaPlayer *self, gint vol, GError **error);
-gboolean meego_media_player_get_volume(MeegoMediaPlayer *self, gint *vol, GError **error);
-gboolean meego_media_player_set_window_id(MeegoMediaPlayer *self, gdouble id, GError **error);
-gboolean meego_media_player_set_video_size(MeegoMediaPlayer *self, guint x, guint y, guint w, guint h, GError **error);
-gboolean meego_media_player_get_video_size(MeegoMediaPlayer *self, guint *w, guint *h, GError **error);
-gboolean meego_media_player_get_buffered_time(MeegoMediaPlayer *self, gint64 *buffered_time, GError **error);
-gboolean meego_media_player_get_buffered_bytes(MeegoMediaPlayer *self, gint64 *buffered_bytes, GError **error);
-gboolean meego_media_player_get_media_size_time(MeegoMediaPlayer *self, gint64 *size_time, GError **error);
-gboolean meego_media_player_get_media_size_bytes(MeegoMediaPlayer *self, gint64 *size_bytes, GError **error);
-gboolean meego_media_player_has_video(MeegoMediaPlayer *self, gboolean *has_video, GError **error);
-gboolean meego_media_player_has_audio(MeegoMediaPlayer *self, gboolean *has_audio, GError **error);
-gboolean meego_media_player_is_streaming(MeegoMediaPlayer *self, gboolean *is_streaming, GError **error);
-gboolean meego_media_player_is_seekable(MeegoMediaPlayer *self, gboolean *is_seekable, GError **error);
-gboolean meego_media_player_support_fullscreen(MeegoMediaPlayer *self, gboolean *support_fullscreen, GError **error);
-gboolean meego_media_player_get_player_state(MeegoMediaPlayer *self, gint *state, GError **error);
-gboolean meego_media_player_reply(MeegoMediaPlayer *self, GError **error);
-gboolean meego_media_player_set_proxy (MeegoMediaPlayer *self, GHashTable *params, GError **error);
-gboolean meego_media_player_suspend (MeegoMediaPlayer *self, GError **error);
-gboolean meego_media_player_restore (MeegoMediaPlayer *self, GError **error);
-gboolean meego_media_player_get_current_video (MeegoMediaPlayer *player, gint *cur_video, GError **err);
-gboolean meego_media_player_get_current_audio (MeegoMediaPlayer *player, gint *cur_audio, GError **err);
-gboolean meego_media_player_set_current_video (MeegoMediaPlayer *player, gint cur_video, GError **err);
-gboolean meego_media_player_set_current_audio (MeegoMediaPlayer *player, gint cur_audio, GError **err);
-gboolean meego_media_player_get_video_num (MeegoMediaPlayer *player, gint *video_num, GError **err);
-gboolean meego_media_player_get_audio_num (MeegoMediaPlayer *player, gint *audio_num, GError **err);
-gboolean meego_media_player_set_subtitle_uri (MeegoMediaPlayer *player, gchar *sub_uri, GError **err);
-gboolean meego_media_player_get_subtitle_num (MeegoMediaPlayer *player, gint *sub_num, GError **err);
-gboolean meego_media_player_get_current_subtitle (MeegoMediaPlayer *player, gint *cur_sub, GError **err);
-gboolean meego_media_player_set_current_subtitle (MeegoMediaPlayer *player, gint cur_sub, GError **err);
-gboolean meego_media_player_set_buffer_depth (MeegoMediaPlayer *player, gint format, gint64 buf_val, GError **err);
-gboolean meego_media_player_get_buffer_depth (MeegoMediaPlayer *player, gint format, gint64 *buf_val, GError **err);
-gboolean meego_media_player_set_mute (MeegoMediaPlayer *player, gint mute, GError **err);
-gboolean meego_media_player_is_mute (MeegoMediaPlayer *player, gint *mute, GError **err);
-gboolean meego_media_player_set_scale_mode (MeegoMediaPlayer *player, gint scale_mode, GError **err);
-gboolean meego_media_player_get_scale_mode (MeegoMediaPlayer *player, gint *scale_mode, GError **err);
-gboolean meego_media_player_get_video_codec (MeegoMediaPlayer *player, gint channel, gchar **video_codec, GError **err);
-gboolean meego_media_player_get_audio_codec (MeegoMediaPlayer *player, gint channel, gchar **audio_codec, GError **err);
-gboolean meego_media_player_get_video_bitrate (MeegoMediaPlayer *player, gint channel, gint *bit_rate, GError **err);
-gboolean meego_media_player_get_audio_bitrate (MeegoMediaPlayer *player, gint channel, gint *bit_rate, GError **err);
-gboolean meego_media_player_get_encapsulation (MeegoMediaPlayer *player, gchar **encapsulation, GError **err);
-gboolean meego_media_player_get_audio_samplerate (MeegoMediaPlayer *player, gint channel, gint *sample_rate, GError **err);
-gboolean meego_media_player_get_video_framerate (MeegoMediaPlayer *player, gint channel, 
-                                        gint * frame_rate_num, gint * frame_rate_denom, GError **err);
-gboolean meego_media_player_get_video_resolution (MeegoMediaPlayer *player, gint channel, 
-                                         gint * width, gint * height, GError **err);
-gboolean meego_media_player_get_video_aspect_ratio (MeegoMediaPlayer *player, gint channel, 
-                                         gint * ratio_num, gint * ratio_denom, GError **err);
-gboolean meego_media_player_get_protocol_name (MeegoMediaPlayer *player, gchar **protocol_name, GError **err);
-gboolean meego_media_player_get_current_uri (MeegoMediaPlayer *player, gchar **uri, GError **err);
-gboolean meego_media_player_get_title (MeegoMediaPlayer *player, gchar **title, GError **err);
-gboolean meego_media_player_get_artist (MeegoMediaPlayer *player, gchar **artist, GError **err);
-gboolean meego_media_player_record (MeegoMediaPlayer *player, gboolean to_record, gchar *location, GError **err);
-gboolean meego_media_player_get_pat (MeegoMediaPlayer *player, GPtrArray **pat, GError **err);
-gboolean meego_media_player_get_pmt (MeegoMediaPlayer *player, guint *program_num, guint *pcr_pid, GPtrArray **stream_info, 
-    GError **err);
-gboolean meego_media_player_get_associated_data_channel (MeegoMediaPlayer *player, gchar **ip, gint *port, GError **err);
-
-G_END_DECLS
-
-#endif /* _MEEGO_MEDIA_PLAYER_H */
--- test/client-test.py
+++ test/client-test.py
@@ -331,9 +331,11 @@
             print "SetVideoSize (%d,%d,%d,%d)" % (x,y,w,h) 
             self.player.SetVideoSize(x,y,w,h)
         elif mid == SetScaleMode:
-            print "Do nothing"
+            mute = int(raw_input ("Scale mode: 0 ~ 3 "))
+            self.player.SetScaleMode(mute)
         elif mid == GetScaleMode:
-            print "Do nothing"
+            scale_mode = self.player.GetScaleMode()
+            print "scale_mode : %d" % scale_mode
         elif mid == GetVideoSize:
         	(width, height) = self.player.GetVideoSize()
         	print "width=%d, height=%d" % (width, height)
@@ -472,6 +474,7 @@
 
 
 #default_uri = "file:///root/video/720p.m4v"
+#default_uri = "file:///root/rpmbuild/BUILD/dvbsub.ts"
 default_uri = "dvb://?program-number=-1&type=0&modulation=1&trans-mod=0&bandwidth=0&frequency=578000000&code-rate-lp=0&code-rate-hp=3&guard=0&hierarchy=0"
 #default_uri = "file:///root/p.mkv"
 default_sub = "file:///root/video/subtest/text-subtitle.srt"
--- ui
+++ ui
-(directory)
--- ui/Makefile.am
+++ ui/Makefile.am
-noinst_PROGRAMS = gtk-UMMS-test
-
-gtk_UMMS_test_CFLAGS = $(UMMS_SAMPLE_UI_CFLAGS)
-gtk_UMMS_test_LDFLAGS = $(UMMS_SAMPLE_UI_LIBS)
-#gtk_UMMS_test_LDADD = ../libummsclient/libummsclient.a
-gtk_UMMS_test_SOURCES = main.c  umms-gtk-backend-gst.c  umms-gtk-backend.h  umms-gtk-player.c  umms-gtk-player.h  umms-gtk-ui.c  umms-gtk-ui.h 
-
--- ui/main.c
+++ ui/main.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include "umms-gtk-ui.h"
-#include "umms-gtk-player.h"
-
-
-int main(int argc, char *argv[])
-{
-    gtk_init(&argc, &argv);
-
-    ui_create();
-    ply_init();
-
-    ui_main_loop();
-
-    return 0;
-}
--- ui/umms-gtk-backend-gst.c
+++ ui/umms-gtk-backend-gst.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <string.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gst/gst.h>
-#include <gdk/gdkx.h> 
-#include <gst/interfaces/xoverlay.h> 
-#include "umms-gtk-backend.h"
-#include "umms-gtk-ui.h"
-
-static GstElement *pipeline;
-static GstElement *video_sink;
-
-static gboolean expose_cb(GtkWidget *widget,GdkEventExpose *event,gpointer data)
-{ 
-    g_print("---->\n");
-    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(data),GDK_WINDOW_XWINDOW(widget->window)); 
-    //gulong video_window_xid = GDK_WINDOW_XID (widget->window);
-    //gst_x_overlay_set_window_handle(GST_X_OVERLAY(data), video_window_xid); 
-    //gst_x_overlay_set_render_rectangle(GST_X_OVERLAY(data), 0,0, 480,320); 
-    return FALSE; 
-}
-
-static gboolean avdec_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
-{
-    GMainLoop *loop = (GMainLoop *) loop;
-
-    switch (GST_MESSAGE_TYPE(msg)) {
-        case GST_MESSAGE_EOS:
-            g_print("End of stream\n");
-            ui_send_stop_signal();
-            break;
-        case GST_MESSAGE_ERROR:
-            g_print("Error\n");
-            g_main_loop_quit(loop);
-            break;
-        default:
-            //g_print("Default branch:%s\n", GST_MESSAGE_TYPE_NAME(msg));
-            break;
-    }
-
-    return TRUE;
-}
-
-static gint avdec_getduration(GstElement *pipeline)
-{
-    GstFormat fmt = GST_FORMAT_TIME;
-    gint64 pos, len;
-    GstState current, pending;
-
-    gst_element_get_state(pipeline, &current, &pending, 0);
-
-
-    gst_element_query_position(pipeline, &fmt, &pos);
-    gst_element_query_duration(pipeline, &fmt, &len);
-    g_print("duration is:%"GST_TIME_FORMAT"/%"GST_TIME_FORMAT"\n", GST_TIME_ARGS(pos), GST_TIME_ARGS(len));
-
-    ui_update_progressbar(pos, len);
-
-    if (current == GST_STATE_PLAYING) {
-        g_timeout_add(500, (GSourceFunc)avdec_getduration, pipeline);
-    }
-
-    return 0;
-}
-
-gint avdec_init(void)
-{
-    GstBus *bus;
-    int argc = 0;
-    char **argv;
-
-    gst_init(&argc, &argv);
-
-    /* Create gstreamer elements */
-    pipeline = gst_element_factory_make("playbin", "playerbin");
-    g_object_get(G_OBJECT(pipeline), "video-sink", &video_sink, NULL);
-    gst_bin_remove(GST_BIN(pipeline), video_sink);
-    video_sink = gst_element_factory_make("ximagesink","video- sink"); 
-    if (!pipeline || !video_sink) {
-        g_printerr("One element can not be created!\n");
-        return -1;
-    }
-
-    /* add message handler */
-    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
-    gst_bus_add_watch(bus, avdec_bus_call, NULL);
-    gst_object_unref(bus);
-
-    g_object_set(G_OBJECT(pipeline), "video-sink", video_sink, NULL);
-
-    //gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(video_sink),
-    //        GDK_WINDOW_XWINDOW(video_image)); 
-    g_signal_connect(video_window, "expose-event", 
-            G_CALLBACK(expose_cb), video_sink); 
-
-
-    return 0;
-}
-
-gint avdec_set_source(gchar *filename)
-{
-    gchar fname[200] = "file://";
-
-    strcat(fname, filename);
-
-    g_object_set(G_OBJECT(pipeline), "uri", fname, NULL);
-
-
-    return 0;
-}
-
-gint avdec_start(void)
-{
-    avdec_seek_from_beginning(0);
-
-    gst_element_set_state(pipeline, GST_STATE_PLAYING);
-
-    g_timeout_add(500, (GSourceFunc)avdec_getduration, pipeline);
-
-    gtk_window_set_focus(GTK_WINDOW(window), video_window);
-
-    //g_signal_emit_by_name(video_window, "expose-event");
-
-    return 0;
-}
-
-gint avdec_stop(void)
-{
-    gst_element_set_state(pipeline, GST_STATE_READY);
-    return 0;
-}
-
-gint avdec_pause(void)
-{
-    gst_element_set_state(pipeline, GST_STATE_PAUSED);
-    return 0;
-}
-
-gint avdec_resume(void)
-{
-    gst_element_set_state(pipeline, GST_STATE_PLAYING);
-    g_timeout_add(500, (GSourceFunc)avdec_getduration, pipeline);
-    return 0;
-}
-
-gint avdec_seek_from_beginning(gint64 nanosecond)
-{
-    gst_element_seek(pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
-            GST_SEEK_TYPE_SET, nanosecond,
-            GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
-    return 0;
-}
-
--- ui/umms-gtk-backend.h
+++ ui/umms-gtk-backend.h
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-
-#ifndef AV_DECODER_H_
-#define AV_DECODER_H_
-
-gint avdec_init(void);
-gint avdec_set_source(gchar *filename);
-gint avdec_start(void);
-gint avdec_stop(void);
-gint avdec_pause(void);
-gint avdec_resume(void);
-gint avdec_seek_from_beginning(gint64 nanosecond);
-
-#endif /* AV_DECODER_H_ */
--- ui/umms-gtk-player.c
+++ ui/umms-gtk-player.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include "umms-gtk-player.h"
-#include "umms-gtk-backend.h"
-
-gchar dbg_state_name[][30] = {
-    "PLY_MAIN_STATE_IDLE",
-    "PLY_MAIN_STATE_READY",
-    "PLY_MAIN_STATE_RUN",
-    "PLY_MAIN_STATE_PAUSE",
-};
-
-static PlyMainData ply_main_data;
-
-gint ply_init(void)
-{
-    ply_main_data.state = PLY_MAIN_STATE_IDLE;
-    avdec_init();
-    return 0;
-}
-
-PlyMainData *ply_get_maindata(void)
-{
-    return &ply_main_data;
-}
-
-
-PlyMainState ply_get_state(void)
-{
-    return ply_main_data.state;
-}
-
-gint ply_reload_file(gchar *filename)
-{
-    if (ply_main_data.state != PLY_MAIN_STATE_IDLE &&
-            ply_main_data.state != PLY_MAIN_STATE_READY) {
-        ply_stop_stream();
-    }
-
-    //g_string_assign(&ply_main_data.filename, filename);
-    avdec_set_source(filename);
-    ply_main_data.state = PLY_MAIN_STATE_READY;
-
-    g_print("%s\n", dbg_state_name[ply_main_data.state]);
-    return 0;
-}
-
-gint ply_play_stream(void)
-{
-    avdec_start();
-    ply_main_data.state = PLY_MAIN_STATE_RUN;
-
-    g_print("%s\n", dbg_state_name[ply_main_data.state]);
-    return 0;
-}
-
-gint ply_stop_stream(void)
-{
-    /* If main state is idle or ready, remain its current state */
-    if (ply_main_data.state != PLY_MAIN_STATE_IDLE &&
-            ply_main_data.state != PLY_MAIN_STATE_READY) {
-        avdec_stop();
-        ply_main_data.state = PLY_MAIN_STATE_READY;
-    }
-
-    g_print("%s\n", dbg_state_name[ply_main_data.state]);
-    return 0;
-}
-
-gint ply_pause_stream(void)
-{
-    if (ply_main_data.state == PLY_MAIN_STATE_RUN) {
-        ply_main_data.state = PLY_MAIN_STATE_PAUSE;
-        avdec_pause();
-    }
-
-    g_print("%s\n", dbg_state_name[ply_main_data.state]);
-    return 0;
-}
-
-gint ply_resume_stream(void)
-{
-    if (ply_main_data.state == PLY_MAIN_STATE_PAUSE) {
-        ply_main_data.state = PLY_MAIN_STATE_RUN;
-        avdec_resume();
-    }
-
-    g_print("%s\n", dbg_state_name[ply_main_data.state]);
-    return 0;
-}
-
-gint ply_seek_stream_from_beginging(gint64 nanosecond)
-{
-    avdec_seek_from_beginning(nanosecond);
-    return 0;
-}
-
--- ui/umms-gtk-player.h
+++ ui/umms-gtk-player.h
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-
-#ifndef PLAYER_CORE_H_
-#define PLAYER_CORE_H_
-
-typedef enum _PlyMainState {
-    PLY_MAIN_STATE_IDLE,
-    PLY_MAIN_STATE_READY,
-    PLY_MAIN_STATE_RUN,
-    PLY_MAIN_STATE_PAUSE,
-}PlyMainState;
-
-typedef struct _PlyMainData {
-    PlyMainState state;
-    GString filename;
-    gint64 duration_nanosecond;
-}PlyMainData;
-
-/***
- * @brief Play Core module init
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_init(void);
-
-PlyMainData *ply_get_maindata(void);
-
-/***
- * @brief Get player main state
- *
- * @return PlyMainState
- */
-PlyMainState ply_get_state(void);
-
-/***
- * @brief Reload file and play it, this function returns without block.
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_reload_file(gchar *file_name);
-
-/***
- * @brief Play the stream from the very beginning, this function just needs to send the message to AV decoder thread, and returns without block.
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_play_stream(void);
-
-/***
- * @brief Stop the stream, this function just needs to send the message to AV decoder thread, and returns without block.
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_stop_stream(void);
-
-/***
- * @brief Pause the stream, this function just needs to send the message to AV decoder thread, and returns without block.
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_pause_stream(void);
-
-/***
- * @brief Resume the paused stream, this function just needs to send the message to AV decoder thread, and returns without block.
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_resume_stream(void);
-
-/***
- * @brief Seek the stream, this function just needs to send the message to AV decoder thread, and returns without block.
- *
- * @param ts if negative means rewind, if positive means forward, the unit is second
- * @return 0 if ok, otherwise it is the error code
- */
-gint ply_seek_stream_from_beginging(gint64 nanosecond);
-
-#endif /* PLAYER_CORE_H_ */
--- ui/umms-gtk-ui.c
+++ ui/umms-gtk-ui.c
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <glib.h>
-#include <glib/gprintf.h>
-#include <gtk/gtk.h>
-#include <gst/gst.h>
-#include "umms-gtk-player.h"
-#include "umms-gtk-ui.h"
-
-#define MY_GST_TIME_ARGS(t) \
-            GST_CLOCK_TIME_IS_VALID (t) ? \
-        (guint) (((GstClockTime)(t)) / (GST_SECOND * 60 * 60)) : 99, \
-        GST_CLOCK_TIME_IS_VALID (t) ? \
-        (guint) ((((GstClockTime)(t)) / (GST_SECOND * 60)) % 60) : 99, \
-        GST_CLOCK_TIME_IS_VALID (t) ? \
-        (guint) ((((GstClockTime)(t)) / GST_SECOND) % 60) : 99
-
-GtkWidget *video_window;
-GtkWidget *window;
-
-static GtkWidget *button_play;
-static GtkWidget *progressbar;
-static GtkWidget *progress_time;
-static GtkWidget *image_play;
-static GtkWidget *image_pause;
-
-static void ui_pause_bt_cb(GtkWidget *widget, gpointer data)
-{
-    if (ply_get_state() == PLY_MAIN_STATE_READY) {
-        ply_play_stream();
-        gtk_container_remove(GTK_CONTAINER(button_play), image_play);
-        gtk_container_add(GTK_CONTAINER(button_play), image_pause);
-    } else if (ply_get_state() == PLY_MAIN_STATE_RUN) {
-        ply_pause_stream();
-        gtk_container_remove(GTK_CONTAINER(button_play), image_pause);
-        gtk_container_add(GTK_CONTAINER(button_play), image_play);
-    } else if (ply_get_state() == PLY_MAIN_STATE_PAUSE) {
-        ply_resume_stream();
-        gtk_container_remove(GTK_CONTAINER(button_play), image_play);
-        gtk_container_add(GTK_CONTAINER(button_play), image_pause);
-    }
-    gtk_widget_show_all(window);
-}
-
-static void ui_stop_bt_cb(GtkWidget *widget, gpointer data)
-{
-    if (ply_get_state() == PLY_MAIN_STATE_RUN) {
-        ply_stop_stream();
-        gtk_container_remove(GTK_CONTAINER(button_play), image_pause);
-        gtk_container_add(GTK_CONTAINER(button_play), image_play);
-    } else if (ply_get_state() == PLY_MAIN_STATE_PAUSE) {
-        ply_stop_stream();
-    }
-}
-
-static void ui_fileopen_dlg(GtkWidget *widget, gpointer data)
-{
-    GtkWidget *fileopen_dlg;
-    gint result;
-    gchar *filename;
-
-    fileopen_dlg = gtk_file_chooser_dialog_new("Select media file",
-            GTK_WINDOW(window),
-            GTK_FILE_CHOOSER_ACTION_OPEN,
-            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-            GTK_STOCK_OK, GTK_RESPONSE_OK,
-            NULL);
-    result = gtk_dialog_run(GTK_DIALOG(fileopen_dlg));
-    if (GTK_RESPONSE_OK == result) {
-        filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fileopen_dlg));
-        gtk_widget_destroy(fileopen_dlg);
-        g_print("filename is %s\n", filename);
-        ply_reload_file(filename);
-        ui_pause_bt_cb(widget, data);
-        g_free(filename);
-    } else {
-        gtk_widget_destroy(fileopen_dlg);
-    }
-}
-
-static void ui_progressbar_vchange_cb( GtkAdjustment *get,
-        GtkAdjustment *set )
-{
-    PlyMainData *ply_maindata;
-
-    g_print("fasfafafasfafsa:%f\n", get->value);
-    if (ply_get_state() == PLY_MAIN_STATE_RUN ||
-            ply_get_state() == PLY_MAIN_STATE_PAUSE) {
-        ply_maindata = ply_get_maindata();
-        ply_seek_stream_from_beginging((get->value/get->upper) * ply_maindata->duration_nanosecond);
-    }
-}
-
-void ui_send_stop_signal(void)
-{
-    ui_stop_bt_cb(NULL, NULL);
-}
-
-void ui_update_progressbar(gint64 pos, gint64 len)
-{
-    PlyMainData *ply_maindata;
-    gchar label_str[30];
-
-    GtkAdjustment *adj = gtk_range_get_adjustment(GTK_RANGE(progressbar));
-    if( (len/GST_SECOND) != 0)
-    {
-        adj->value = ((pos/GST_SECOND) * 1000) / (len/GST_SECOND);
-    }
-    if ( (len/GST_SECOND) == 0 ||
-            adj->value > 1000)
-    {
-        adj->value = 1000;
-        pos = len;
-    }
-
-    if (ply_get_state()== PLY_MAIN_STATE_READY) {
-        pos = 0;
-        adj->value = 0;
-    }
-
-    ply_maindata = ply_get_maindata();
-    ply_maindata->duration_nanosecond = len;
-
-    gtk_signal_emit_by_name(GTK_OBJECT(adj), "changed");
-    g_sprintf(label_str, "%02u:%02u:%02u/%02u:%02u:%02u", 
-            MY_GST_TIME_ARGS(pos), MY_GST_TIME_ARGS(len));
-    gtk_label_set_text(GTK_LABEL(progress_time), label_str);
-    g_print("%s\n", label_str);
-    gtk_widget_show_all(progress_time);
-}
-
-
-gint ui_create(void)
-{
-    GtkWidget *topvbox;
-
-    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    gtk_widget_set_size_request(window, 640, 480);
-    gtk_window_set_title(GTK_WINDOW(window), "AdvPlayer");
-    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
-    g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
-
-
-    /* Create Top vertical box */
-    topvbox = gtk_vbox_new(FALSE, 0);
-    gtk_container_add(GTK_CONTAINER(window), topvbox);
-
-    /* Create MenuBar */
-    GtkWidget *menubar;
-    GtkWidget *menuitem_file;
-    GtkWidget *menuitem_play;
-    GtkWidget *menuitem_help;
-    GtkWidget *file_menu;
-    GtkWidget *play_menu;
-    GtkWidget *help_menu;
-    menubar  = gtk_menu_bar_new();
-    gtk_box_pack_start(GTK_BOX(topvbox), menubar, FALSE, TRUE, 0);
-    menuitem_file = gtk_menu_item_new_with_mnemonic("File(_F)");
-    gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem_file);
-    file_menu = gtk_menu_new();
-    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem_file), file_menu);
-    GtkWidget *menuitem_file1 = gtk_menu_item_new_with_mnemonic("File(_F)");
-    gtk_container_add(GTK_CONTAINER(file_menu), menuitem_file1);
-
-    menuitem_play = gtk_menu_item_new_with_mnemonic("Play(_P)");
-    //gtk_container_add(GTK_CONTAINER(menubar), menuitem_play);
-    gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem_play);
-    play_menu = gtk_menu_new();
-    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem_play), play_menu);
-
-    menuitem_help = gtk_menu_item_new_with_label("Help(_P)");
-    //gtk_container_add(GTK_CONTAINER(menubar), menuitem_help);
-    gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem_help);
-    help_menu = gtk_menu_new();
-    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem_help), help_menu);
-    gtk_widget_show_all(window);
-
-    /* image widget */
-    video_window = gtk_drawing_area_new();
-    gtk_widget_set_size_request(video_window,640,380); 
-    gtk_box_pack_start(GTK_BOX(topvbox), video_window, FALSE, FALSE, 0);
-
-    /* progress widget */
-    GtkWidget *progress_hbox;
-    progress_hbox = gtk_hbox_new(FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(topvbox), progress_hbox, TRUE, TRUE, 0);
-    progressbar = gtk_hscale_new_with_range(0, 1000, 1);
-    gtk_scale_set_digits(GTK_SCALE(progressbar), 0);
-    gtk_scale_set_draw_value(GTK_SCALE(progressbar), FALSE);
-    gtk_widget_set_size_request(progressbar, 32, 20);
-    GtkAdjustment *adj = gtk_range_get_adjustment(GTK_RANGE(progressbar));
-    gtk_signal_connect(GTK_OBJECT(adj), "value_changed", GTK_SIGNAL_FUNC(ui_progressbar_vchange_cb), adj);
-    gtk_box_pack_start(GTK_BOX(progress_hbox), progressbar, TRUE, TRUE, 0);
-    progress_time = gtk_label_new("00:00:00/00:00:00");
-    gtk_box_pack_start(GTK_BOX(progress_hbox), progress_time, FALSE, FALSE, 0);
-
-    /* Control Button */
-    GtkWidget *button_hbox;
-    GtkWidget *button_rewind;
-    GtkWidget *button_stop;
-    GtkWidget *button_forward;
-    GtkWidget *button_fileopen;
-    GtkWidget *image_rewind;
-    GtkWidget *image_stop;
-    GtkWidget *image_forward;
-    GtkWidget *image_fileopen;
-    button_hbox = gtk_hbox_new(FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(topvbox), button_hbox, FALSE, FALSE, 0);
-    button_rewind = gtk_button_new();
-    image_rewind = gtk_image_new_from_stock("gtk-media-rewind", GTK_ICON_SIZE_BUTTON);
-    gtk_container_add(GTK_CONTAINER(button_rewind), image_rewind);
-    gtk_box_pack_start(GTK_BOX(button_hbox), button_rewind, TRUE, TRUE, 0);
-    button_play = gtk_button_new();
-    image_play = gtk_image_new_from_stock("gtk-media-play", GTK_ICON_SIZE_BUTTON);
-    image_pause = gtk_image_new_from_stock("gtk-media-pause", GTK_ICON_SIZE_BUTTON);
-    g_object_ref((gpointer)image_play);
-    g_object_ref((gpointer)image_pause);
-    gtk_container_add(GTK_CONTAINER(button_play), image_play);
-    gtk_box_pack_start(GTK_BOX(button_hbox), button_play, TRUE, TRUE, 0);
-    button_stop = gtk_button_new();
-    image_stop = gtk_image_new_from_stock("gtk-media-stop", GTK_ICON_SIZE_BUTTON);
-    gtk_container_add(GTK_CONTAINER(button_stop), image_stop);
-    gtk_box_pack_start(GTK_BOX(button_hbox), button_stop, TRUE, TRUE, 0);
-    button_forward = gtk_button_new();
-    image_forward = gtk_image_new_from_stock("gtk-media-forward", GTK_ICON_SIZE_BUTTON);
-    gtk_container_add(GTK_CONTAINER(button_forward), image_forward);
-    gtk_box_pack_start(GTK_BOX(button_hbox), button_forward, TRUE, TRUE, 0);
-    button_fileopen = gtk_button_new();
-    image_fileopen = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
-    gtk_container_add(GTK_CONTAINER(button_fileopen), image_fileopen);
-    gtk_box_pack_start(GTK_BOX(button_hbox), button_fileopen, TRUE, TRUE, 0);
-
-    g_signal_connect((gpointer)button_fileopen, "clicked", G_CALLBACK(ui_fileopen_dlg), NULL);
-    g_signal_connect((gpointer)button_play, "clicked", G_CALLBACK(ui_pause_bt_cb), NULL);
-    g_signal_connect((gpointer)button_stop, "clicked", G_CALLBACK(ui_stop_bt_cb), NULL);
-
-    gtk_widget_show_all(window);
-
-
-    return 0;
-}
-
-void ui_main_loop(void)
-{
-    gtk_main();
-}
--- ui/umms-gtk-ui.h
+++ ui/umms-gtk-ui.h
-/* 
- * UMMS (Unified Multi Media Service) provides a set of DBus APIs to support
- * playing Audio and Video as well as DVB playback.
- *
- * Authored by Zhiwen Wu <zhiwen.wu at intel.com>
- *             Junyan He <junyan.he at intel.com>
- * Copyright (c) 2011 Intel Corp.
- * 
- * UMMS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * UMMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with UMMS; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef UI_H_
-#define UI_H_
-
-extern GtkWidget *video_window;
-extern GtkWidget *window;
-
-/***
- * @brief Create UI main framework
- *
- * @return 0 if ok, otherwise it is the error code
- */
-gint ui_create(void);
-
-/***
- * @brief Application main loop
- *
- * @return none
- */
-void ui_main_loop(void);
-
-/***
- * @brief send stop player signal, this function will change the icon, and stop the player.
- *
- * @return none
- */
-void ui_send_stop_signal(void);
-void ui_update_progressbar(gint64 pos, gint64 len);
-
-#endif /* UI_H_ */



More information about the MeeGo-commits mailing list