pax_global_header00006660000000000000000000000064121340734370014516gustar00rootroot0000000000000052 comment=9f36336b26dcb27471fa7e10cb16044b94352942 snappy-0.3.7/000077500000000000000000000000001213407343700130375ustar00rootroot00000000000000snappy-0.3.7/.gitignore000066400000000000000000000010101213407343700150170ustar00rootroot00000000000000.gitignore Makefile Makefile.in aclocal.m4 autom4te.cache/ build-aux/ config.h config.h.in config.log config.status configure data/Makefile data/Makefile.in data/icons/256x256/Makefile data/icons/256x256/Makefile.in data/icons/48x48/Makefile data/icons/48x48/Makefile.in data/icons/Makefile data/icons/Makefile.in libtool m4/ src/.deps/ src/Makefile src/Makefile.in src/snappy src/snappy-dlna.o src/snappy-gst_engine.o src/snappy-screensaver.o src/snappy-snappy.o src/snappy-user_interface.o src/snappy-utils.o stamp-h1 snappy-0.3.7/AUTHORS000066400000000000000000000006131213407343700141070ustar00rootroot00000000000000Copyright (2011-2013) Collabora Ltd. Luis de Bethencourt Guimera Robert Swain Sebastian Dröge Alban Crequy Andoni Morales Alastruey Bastien Nocera Bjørn Lie David Schleef Deirdre Kelly Edward Hervey Emmanuele Bassi Jens Georg Konstantinos Papagiannopoulos George Danchev Nicolas Dufresne Nirbheek Chauhan Phillipe Coval Tim Philipp Muller Wim Taymans snappy-0.3.7/COPYING000066400000000000000000000354221213407343700141000ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 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. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, 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 or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's 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 give any other recipients of the Program a copy of this License along with the Program. 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 Program or any portion of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, 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 Program, 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 Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) 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; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, 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 executable. However, as a special exception, the source code 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. If distribution of executable or 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 counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program 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. 5. 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 Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program 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 to this License. 7. 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 Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program 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 Program. 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. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program 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. 9. The Free Software Foundation may publish revised and/or new versions of the 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 Program 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 Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, 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 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS snappy-0.3.7/ChangeLog000066400000000000000000000000001213407343700145770ustar00rootroot00000000000000snappy-0.3.7/INSTALL000066400000000000000000000363321213407343700140770ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. snappy-0.3.7/Makefile.am000066400000000000000000000012101213407343700150650ustar00rootroot00000000000000AUTOMAKE_OPTIONS = 1.7 SUBDIRS = \ src data DIST_SUBDIRS = $(SUBDIRS) EXTRA_DIST = \ ChangeLog autogen.sh \ AUTHORS COPYING NEWS README ToDo pkgconfigdir = $(libdir)pkgconfig ACLOCAL_AMFLAGS = DISTCLEANFILES = all-local: dist-hook: @if test -d "$(srcdir)/.git"; \ then \ echo Creating ChangeLog && \ ( cd "$(top_srcdir)" && \ echo '# Generated by Makefile. Do not edit.'; echo; \ git log --stat ) > ChangeLog.tmp \ && mv -f ChangeLog.tmp $(distdir)/ChangeLog \ || ( rm -f ChangeLog.tmp ; \ echo Failed to generate ChangeLog >&2 ); \ else \ echo A git clone is required to generate a ChangeLog >&2; \ fi snappy-0.3.7/NEWS000066400000000000000000000000001213407343700135240ustar00rootroot00000000000000snappy-0.3.7/README000066400000000000000000000010121213407343700137110ustar00rootroot00000000000000snappy version 0.1 - "Louis, I think this is the beginning of a beautiful friendship." 2011-03-25 version 0.2 - "Mrs. Robinson, you're trying to seduce me." 2011-06-20 version 0.3 - "Rosebud." CiTIZEN Kane 2013-03-24 get the source from: http://git.gnome.org/snappy report bugs at: https://bugzilla.gnome.org/browse.cgi?product=snappy contact: snappy-list@gnome.org project page: http://projects.gnome.org/snappy/ wiki: https://live.gnome.org/snappy snappy-0.3.7/THANKS000066400000000000000000000006041213407343700137520ustar00rootroot00000000000000Thanks to all the people that helped the project with patches, guidance and/or answers: Alban Crequy Andoni Morales Alastruey Andy Wingo Bastien Nocera Bjørn Lie David Schleef Deirdre Kelly Edward Hervey Emmanuele Bassi Jens Georg Konstantinos Papagiannopoulos George Danchev Nicolas Dufresne Nirbheek Chauhan Philippe Coval Robert Swain Sebastian Dröge Tim Philipp Muller Wim Taymans snappy-0.3.7/ToDo000066400000000000000000000001431213407343700136250ustar00rootroot00000000000000To view planned features or suggest new ones: https://bugzilla.gnome.org/browse.cgi?product=snappy snappy-0.3.7/autogen.sh000077500000000000000000000007211213407343700150400ustar00rootroot00000000000000#!/bin/sh # Run this to generate all the initial makefiles, etc. srcdir=`dirname $0` test -z "$srcdir" && srcdir=. PKG_NAME="snappy" (test -f $srcdir/configure.ac \ && test -d $srcdir/src \ && test -f $srcdir/src/snappy.c) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" echo " top-level snappy directory" exit 1 } which gnome-autogen.sh || { echo "You need to install gnome-common" exit 1 } . gnome-autogen.sh snappy-0.3.7/configure.ac000066400000000000000000000100451213407343700153250ustar00rootroot00000000000000AC_PREREQ(2.60) dnl initialize autoconf dnl when going to/from release please set the nano (fourth number) right ! dnl releases only do Wall, cvs and prerelease does Werror too AC_INIT([snappy], [0.3.7], NULL, snappy) AM_MAINTAINER_MODE AC_CONFIG_SRCDIR([src/snappy.c]) AM_CONFIG_HEADER([config.h]) AC_CONFIG_AUX_DIR([build-aux]) dnl initialize automake AM_INIT_AUTOMAKE([1.11.1 no-dist-gzip dist-xz dist-bzip2 tar-ustar]) dnl use pretty build output with automake >= 1.11 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])], [AM_DEFAULT_VERBOSITY=1 AC_SUBST(AM_DEFAULT_VERBOSITY)]) m4_define([_LT_AC_TAGCONFIG],[]) dnl find a compiler AC_PROG_CC AM_PROG_CC_C_O AC_STDC_HEADERS AM_PROG_LIBTOOL dnl instruct libtool machinery that the package supports DLLs AC_LIBTOOL_WIN32_DLL AC_CANONICAL_HOST # keep one single GST_REQ, core/base should be same versions anyway GST_REQ=1.0.0 CLUTTER_REQS=1.12.0 CLUTTER_GST_REQS=1.5.5 CLUTTER_GTK_REQS=1.0.2 GTK_REQS=3.5.0 GIO_REQ=2.32 PKG_CHECK_MODULES([GST], \ [gstreamer-1.0 >= $GST_REQ gstreamer-base-1.0 >= $GST_REQ gstreamer-pbutils-1.0 >= $GST_REQ gstreamer-video-1.0 >= $GST_REQ]) AC_SUBST(GST_CFLAGS) AC_SUBST(GST_LIBS) PKG_CHECK_MODULES([CLUTTER], [clutter-1.0 >= $CLUTTER_REQS]) AC_SUBST(CLUTTER_CFLAGS) AC_SUBST(CLUTTER_LIBS) PKG_CHECK_MODULES([CLUTTER_GST], [clutter-gst-2.0 >= $CLUTTER_GST_REQS]) AC_SUBST(CLUTTER_GST_CFLAGS) AC_SUBST(CLUTTER_GST_LIBS) PKG_CHECK_MODULES([CLUTTER_GTK], [clutter-gtk-1.0 >= $CLUTTER_GTK_REQS]) AC_SUBST(CLUTTER_GTK_CFLAGS) AC_SUBST(CLUTTER_GTK_LIBS) PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_REQS]) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) PKG_CHECK_MODULES(GIO, gio-2.0 >= $GIO_REQ) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) case "$host" in *-*-mingw*|*-*-cygwin*) PKG_CHECK_MODULES(CLUTTER_WIN32, clutter-win32-1.0, [AC_DEFINE(HAVE_WIN32, 1, [Define if Clutter Win32 is available.])], []) ;; *-*-darwin*) PKG_CHECK_MODULES(CLUTTER_OSX, clutter-osx-1.0, [AC_DEFINE(HAVE_OSX, 1, [Define if Clutter OSX is available.])], [ PKG_CHECK_MODULES(CLUTTER_X11, clutter-x11-1.0, [AC_DEFINE(HAVE_X11, 1, [Define if Clutter X11 is available.])], []) ]) ;; *) PKG_CHECK_MODULES(CLUTTER_X11, clutter-x11-1.0, [AC_DEFINE(HAVE_X11, 1, [Define if Clutter X11 is available.])], []) ;; esac PKG_CHECK_MODULES(XTEST, xtst, [AC_DEFINE(HAVE_XTEST, 1, [Define if XTest is available.])], [true]) AC_SUBST(XTEST_CFLAGS) AC_SUBST(XTEST_LIBS) AC_ARG_ENABLE([dbus], AS_HELP_STRING([--enable-dbus], [enable DBus support to disable the screensaver (default=yes)]), [], [enable_dbus=yes]) if test "x$enable_dbus" = "xyes"; then PKG_CHECK_MODULES(GIO_2_26, gio-2.0 >= 2.26, [AC_DEFINE(ENABLE_DBUS, 1, [Define if DBus support is enabled.])], [AC_MSG_ERROR([GIO >= 2.26 not found, which is required for DBus support])]) fi dnl our libraries and install dirs use major.minor as a version GST_MAJORMINOR=$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR dnl we override it here if we need to for the release candidate of new series GST_MAJORMINOR=0.10 AC_SUBST(GST_MAJORMINOR) AM_PROG_LIBTOOL dnl Add parameters for aclocal AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I common/m4") AC_CONFIG_MACRO_DIR([m4]) ROOT_UNINSTALLED_DIR="`pwd`" AC_DEFINE_UNQUOTED(SHARE_UNINSTALLED_DIR,"`pwd`/$srcdir/data",[path to source data dir]) AC_DEFINE_UNQUOTED(SHARE_UNINSTALLED_BUILDDIR,"`pwd`/data",[path to built source data dir]) AC_SUBST(ROOT_UNINSTALLED_DIR) dnl set license and copyright notice GST_LICENSE="LGPL" AC_DEFINE_UNQUOTED(GST_LICENSE, "$GST_LICENSE", [GStreamer license]) AC_SUBST(GST_LICENSE) dnl keep this alphabetic per directory, please AC_CONFIG_FILES([ Makefile data/Makefile data/icons/Makefile data/icons/256x256/Makefile data/icons/48x48/Makefile src/Makefile ]) AC_OUTPUT echo " Configuration Version : ${VERSION} Source code location : ${srcdir} Prefix : ${prefix} Compiler : ${CC} snappy configured. Type 'make' to build. " snappy-0.3.7/data/000077500000000000000000000000001213407343700137505ustar00rootroot00000000000000snappy-0.3.7/data/AUTHORS000066400000000000000000000005141213407343700150200ustar00rootroot00000000000000Ulisse Perusin Steven Garrity Lapo Calamandrei Ryan Collier Rodney Dawes Andreas Nilsson Tuomas Kuosmanen Garrett LeSage Jakub Steiner snappy-0.3.7/data/Makefile.am000066400000000000000000000006551213407343700160120ustar00rootroot00000000000000SUBDIRS = icons icons_DATA = \ audio-stream-toggle.png \ audio-volume-high.svg \ audio-volume-low.svg \ fullscreen.svg \ media-actions-pause.svg \ media-actions-start.svg \ subtitles-active.svg \ subtitles-inactive.svg \ video-stream-toggle.png iconsdir = $(datadir)/snappy desktop_DATA = snappy.desktop desktopdir = $(datadir)/applications EXTRA_DIST = \ $(icons_DATA) $(desktop_DATA) snappy-0.3.7/data/README000066400000000000000000000007541213407343700146360ustar00rootroot00000000000000copied from... Tango Icon Theme ---------------- This is an icon theme that follows the Tango visual guidelines [1]. Currently it depends on Imagemagick for creation of 24x24 bitmaps by adding a 1px padding around the 22x22px version. For GNOME and KDE you will also need icon-naming-utils that allow the theme to work in these environments before they follow the new naming scheme [2]. [1] http://tango.freedesktop.org [2] http://tango.freedesktop.org/Standard_Icon_Naming_Specification snappy-0.3.7/data/audio-stream-toggle.png000066400000000000000000000051471213407343700203360ustar00rootroot00000000000000PNG  IHDRdd]sRGBbKGD̿ pHYs B(xtIME!B(P IDATx[l#gf;dwވ$enRZ UA]BحP}j *҇V< U}KR*DlYT.E& 6{67gǞsxƷ$,+#G| tF7эnt8g!i?LZwD2dH3D4w+&*L&#Ҥc#y: doD\a5,v)O1 E$ zgyn.m;԰fa_NY&H)$c C)! {maR.'CKs-QlwnHRma߮]Fg#Ȉ:_^\NIE2FCÆVhdZ~7!)ɱHjnk3 gVC褹$ѼaXlZo*G4ΪdmjG3}D^e4.1MeF1 =g:_nPWxwRUu 7 3V2zD#]~&ҞcwHvZ ,zHb`"( Ѓ QikIC"8hDq=%Vs0PDe Swd'i. Qu, Bgw@1M $7)BpSodf~vg'K&DZ&zq8Ea#qqp85o42q3-ӧ?^02{S@'V_Z꒯…@xظU9d!y,~8ۆ@DO_e^ab'>zZHY( u_j @;ğG/q(q|#޿'=*C.I~lqY&,y'^O_uF5H|ek~ƺ;KZ}޶n%Ү{('h{(a~Ԫ =[eRY/'Ws!?=zT ƠVG3 nؙQq=[(../~xx>~-W*tTs]sg%:}K?\bP*@`T s-.Bys[agARȪfXi+C OE fEXFdI+d;Tz#kV֟W#[`H\EX+Vz<T}aՊŹ՛-TZ5b9F>dWϽDF&'z>Y4fF7Z`|aG)IENDB`snappy-0.3.7/data/audio-volume-high.svg000066400000000000000000000101631213407343700200150ustar00rootroot00000000000000 snappy-0.3.7/data/audio-volume-low.svg000066400000000000000000000025641213407343700177050ustar00rootroot00000000000000 snappy-0.3.7/data/fullscreen.svg000066400000000000000000000046701213407343700166420ustar00rootroot00000000000000 snappy-0.3.7/data/icons/000077500000000000000000000000001213407343700150635ustar00rootroot00000000000000snappy-0.3.7/data/icons/256x256/000077500000000000000000000000001213407343700160245ustar00rootroot00000000000000snappy-0.3.7/data/icons/256x256/Makefile.am000066400000000000000000000001421213407343700200550ustar00rootroot00000000000000icondir = $(datadir)/icons/hicolor/256x256/apps icon_DATA = snappy.png EXTRA_DIST = $(icon_DATA) snappy-0.3.7/data/icons/256x256/snappy.png000066400000000000000000000510221213407343700200440ustar00rootroot00000000000000PNG  IHDR\rfsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org< IDATxw|y.-XtD!H@IMv\bӖĉܟ}͍oU&qb'vlK]d[ݒl%v HDby?vgvfvfvvh<{{yy3 p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p… .\p]6 p1:BUKX5J|WꖳT5p wF&1{Z'"d>eN2\FD|9M_4qs$%pqKX#!(0>3k5.n9>MwH|M _Pp10rjH`ap>=T7V)M?BŴ$%:-tRnzzSj0]j\0=Nh!Fǀ`iB枳B|]R|8#p=-ΧF##ǎz8M%iCj\P0v% FOC~"R i J]ȯ "bt9ˀL>3>3݌mjўeMl?8z.#fpH|f|ҭ4^xx5.Ĉ= :fȟ?nD 8[E:i2ؿ+$~RJ翉~GWJ2Nioj bJ0z<ofooW~E\فkJrMQԩ5{c(7J|<ď%$K"kP(ϪSen6رGJc^"uə/ V Ɋ@匆k\L*L#Fzn"[ډ_je\I~F[ {݋ʲjECϿæMj*]D7nyRvd1zpor1i9E5H&;T(iܧ W10EP__2bq llي^CMx^޽-YD۷C4ƭ=0$(&mjH3%p=d#H?t^92# "TTT`Xd !m$O@@U{EMMM6ݍH(‡&& p1) }$786!vmgB(IiGw$5.&Dh!Wx1\Fkk+*++uyڰ' ;108:_GU܌eo^/.Np IZiy\ hmmەXU ym*J "3Uap1|;D;d @EכهJaE|!NJY P J@SR z޼ g$o&Jf{W@`m =ˋa t9ʞqSq JTV.kI(*-d_weE1|00 F+0%>2D@S"$IGv'|nx Fу(*ߊD:k'SZpҵ sstϩe=7{PZ%rPhɕz+'pQ4 3zs&WuX۵|7uuu!P%0p`6p qފ</g<'OC|/ )%5|F^O4FI,NNܧ] G2)m֦чY\TX~k8y`ժUXfM<߰6NzfEzT5P͡ν1x8Iђ|743Al۶ 6lc,]wh_v >?}H PE!3pQt@l7%>?Sg:B {^,[ @7 k+G>xymp| M\}]}돃G]]݋R5_+k ;us_뺆&tiKѕVCKGp}oU-O$_>#˖-E4o^cvW,u55.n %z@Dd'F_| 1[bٲekua'd7+;<<S*"9&宗Nlս cp ;4{¹vA<a`\daI_Kct9 /N-[5?|;::hn _x}.t;]zAɉ ]gtu{'aưQ^fUIpU 7do ƧMAz? >og' s555طo***&l7\q}!qA@t8uI0oH>oob]БD&,K᯾7-Z;wO |^y|=HZyQ|=IeDr9pq^b`T11>$Mˌ1^H[˒qs `tlx˸s aXBw?7SOa^A wtt`@G_F/5.0r2"Zdb1gPi7daXdH;IoˍY$W's=wng3Ak=񍧾ѱ|>ܹMMMiə'8DQlc16M_m40E>]H0AXu LzK`4D70^ӯGz Duu5ݫ{AIs'‹Xt)V.XcC|5(K&k[?:iL2FIs@(25YjAWl)FJ:ԡsx'xs bǎu{^GqśಒM|%Il4k& cDOl )myIb:3uDFx+VYǫOqj߉!_!ԝ䜥c`2_]p&Ǣ yȉ>DƷj)*/|'W3|>vءuXahll(CƘ%Gz1M 1¿J]$_aHV᯿DEEك q'ˋjgصk$ D?X4k&ᷨ>M|ޛ)#ag׏">2~F+F}5+;/_ 6@E$$\ԽھR0{(2މHij ,P=Mt#ݮbqIʕ+n:iD/'2@;v]c969m}("FE7w ".<3Dxuuuصk***%BAt7+ %`5E~Rm&2~_:=Q$$˱{n̚5Bg33ƛQQQH#J:$>0"`>"|oQ1@,2qm`A|W/z[h cze)\P qy{jK|c/\g*xbbΜ9(--WD"¡K7~EuK{=XhU^ @4AII n444Lڪ>'2CH2A O @,N5w?َ:zJJJ҂K dc ,P}}}~媌 "x9<} fž={PZZ֭社ԧɽЀ%]E~} J^e hG𣗿CmʰqF7֓O$8{,J ~,@,_6]|@j[8Uv:L_҆?#rUͳZIOܘl(f\ O طxL]'W/k?֭ڵkU)zXyJqo;ޏ空xǍ`aݺuX|e OQ Bʕ\3+9'E8䉡VMwB|p }aHrf޽{1gz1~?V^o`Yb4T?y({'cرc-Jڕh0˫CI1\p+[m~!4c8q̟?w|>_V=xxD; ~ ONn|ڜ t&: Γaư3 ~)ᑧ Nطo_:[A]RRX^?+\Ƃ }veS.^N0|e4\&0!H8+9#}yTO۫իXtiΗwLb\%I`O 'R3 p7 ޤ@[Oxg߯>z<a'ˋ0S]]={ϟG[[FGG 2H#qE(#C.nY}A|eK}>w^o:3DθQ+V`ӦMErBƬ\ňchkkÅ + |eDoV2t1܊y}&N> 'X|p]wݲoɝ /L`˖-PO]!%e^h^+v9s$;IF+_7>833pG>W¿:|iC|姓aWG2D4E즄o(CD87/êK8uFGGm B< `Z p}Z f$/6n"/--E]]JJJL&166^DQ۲ uݞ"p;Is&%9 0jg=;ޏ ĉ2m+ bVyd_GpOn$@XKruDtN2NoT|O],6Y:7"ܹsXohh@KKMUFN իWGE4r܉D fjEꋠ҇--ky Q?1]ܜJqyfv K6۶wc!av蕏PR/R1غ )'Ł!\uDNeDԓU6m?b FK D(1. H#cJXtX_1pT=sɄ!ć &_8KuFA`"V4dtpcX28iH3)'mg|2L^\?֧ HIEOcaB !oPǂ$}d%[80Ff;cJ0RsLO|ʤU h8xmmg ޡ7|~ !VHo?P FZ5Zh5ϰh"h$D-1ܸ- 6{' lYrHמR&&mc`e.F=2>w\~G݈jѽs>="HDo`q Q@__$\,/bC4$Iz,g|kANj9&6'Acǥ0ϸ%b̡#@|AoEbٯ5xpl1Lt 1/*J%Py3{"Ld.Aww7'ưbP(_7o볍7: W0P/\%@wM0,ѧPD@`%%g@Du5WTTdBd 0DSH$gmn)]1p*#Hߤ JKK!" BVf_)m2f yO XJC|gdZI|M>a_! 4may7)?%^I>_/D"&!Ll3_ ;[hjj®]p5ڵk`0Y&>nRG% 39 I/ʐ~N++^w0r_A/d2圃Gd%]\ z̽*7uq1샿"g ;q7nĪUvN/6n8Ξ;ӧO˥c8oꈘ8@ \#5IPi'_ S}E1taC|E x\z9K{+?V|TB?aZO@'gϟWiXyn0xy7K#]a>bոu'OHN`jx 3&gqK0' IDATz,9"78Y(koNH,c†Ř7 A|MDZ7s3-yN744ھa׃1o >$q\r9wԗە/Wڊm۶BNp\Ý!yz Yj|`ob81'O#]<>R\-D#_ =&7 (6R'.C8uRg0w\L&m)M0gW0vDTU`҅iB}C@ e gȥ͛8ry>۶mm돢MǒpR35]! _ !P]۰uVn?ӧOg-{v,;E%8 T2֮OP'YCPg'"vosNSy_]kk+-Z>( sHnAtӢ܇ "J;"w6ŹSXtiZ8}@"$oms|Dgx^y睓; ֬Y7B$#:߼HveYR\BAfl|螏`89'Nʕ+me>+8w t x$1 W/3pFҷ EnҥKw ,N@EswU8 4u>uNiV9caT_՟`snY [@|ù`aƍe'{OA ݻԔzc0 "' ] bZ*};oouޚ:u"w1tg#Cx Gnc7oZ[[tRj5 cߎJ1&o3t{ X_/T`ќ%SsJr&~W/*gϞ]sll U5Wad߬D IHD!2VX,|IX]]={W:c``H~r44YTl)UUUػw \ckJ_iVѸIꌀ1n8isL0 "ި*lpߟ/x? ٴ SWѝ~H}˖-DS[VHpr5O +?Ϭvz\cT飴cF|@g'+Wd/%/Al?=Y|pkk+oߞ/> _ _#qNޑvIpJY*PQd$ƪ$qU1F5QR7UP Jo#}\#ƞN/T0r$WsdI)uyII ZZZl2455eѦ~ܹ7%Ru1_O Լ;RֹžAz:t~a޲zrHz}v<P/DFVg'c0qk1NB* Tɀ*[MJ""}\i46q›ۊu7%T0|$?8֯_b"-[Fq쯳]ҟEvq@__>}ݦsr;JSDOND?SZ>noNC%$'bha߿>4"d2PJ3%NSy^ ܬܥ]V{y&|ՙ5nzI?4xڋKCUf Ѻv2}.._>f͚e!N*-[H?ec'zj|DUU.Љj_tFˤm[ fa<:MYͬ2ujP&I.NJk` |eG㓏?ALļgD_\&@2nSoųOCHrرCjbpCSSكRp> \U:j_;moSG80CШ;!o?zw| E]Rt<3Д"4:B\Jnӧj\”.]t-4O׫8|JFQ'!%W I0|w}:Vypʏ}Qg}Cii)#q{Z>n_&xy[Yueԁl}ά̼ŀdHM.߄7,elju{8}Vd &euDx2l9@VDJ=W{/_~w{ ^;v5k x:G3+kΝwމ~qnq3k8fmrgg9Sfb)f 錟QU>K{yS=DE %WS-!rF@.d3UYW-|hE|NG/7B JKK{nu$Ozؽ{7mǃch*/ućZgT6}]NY3CvnF ST̮9u)k8%IރXY I{޳h;:jr2ɉ?ëmb۶mO1: a'3a~uu565)ucCmz}SASg9;zԢ&x^4i#4n蠬&<~ 1O /ᩃO;։-[EO@18ad`;fp :!>z;/?òe˰rJk ;b 6lu b:`&t%9I؎:u9v=0wNy?X_fIEi<X7oU7zN98v.$>uїDQT~tcbM@{… Ý!t )܄6}oW2jFˆ'TX!)%KFI$1$8r"MqhXsdKVg( @ 7.p[.˕ 5,>U> cdd{<TUUa֬Y3gMNX^(hiiAEE0ƒc9?p8X2h"X"h2X" KHJIĤ$Atn(j\UxxԙV.Y|~`ߘ!I>_O_"/ ^O~6l4"P`ɒ%hnnVcɤ*]1cML(©S#BOUJS+auT{:}7 hͫ!diiJ~M; t'WA'v;OY\2X ===hhhБUGt #;]ֆ܆@.$ |4_~e_ c'׺,xo`=2OS'8JO}S:0QX_%Y\(=ۭMۤ_3ƀ2@̮EX~8#8 k(cUΪl!SG3y+K|ttw3EǙSNv ϩpQgkv: i[?#aϚ6ӆg D8u4hkkCٺIUd?8r^ղ;˵~10DB[a;i'_'hUI^3h7n^ǜՙDSz86_l)%8%V܋tSIBvrc&wN taz[~жr@x$+W#<]jsJ©5M[ɀMwo={u͂lOD m/!I 숟JJ{+1 s c:ڀhq%/&:Lӿ|Brd;~__x "1$ww:`ѱSXH9 ;[mmmh>Ctk3 r Ο??%|Ih׎UVe€壣Ӿou\x+![ 8l1cмjF2Ʋ3:[L&q9mM' w?ʷqD-Oҭ_Y^\8{1cNz9!Thu =&mގ;:۟oy%տLD/zSz'4NHt wU0w3.]z?|ona | yq|]/4.BY*t%"9ѱifvpq9_C]"+66hx5$n}o9q$+ʀ]dp)[QXZ#NGIߋ!5Nvx!a;ݪl\v "%ч8F偹gط%~*!{7mxrBL/:Zu?>Q X ,Gs*\EH>' D?ͻ#ӊNl1 R.y:Z CQs mmmXjcy!%F=^K|fD"]٩ "9ѱif.$٥_T8׻o{ϼx ЈUqGZB)%n>l0:u4׉_v!N>STB6nX X5 qtLީZyE8}4v `H7m48}cxnkȜ:Y x<+$ 9ѪSR8䣣S8G(1zG=@K(;Mo3⧓,**5c0LB'D҆'PbO]?Kh;Z/W ޤlC]m}VBNd%?VL/3]L N:+1[dx9d#)JcƝז/ 9:;Ѫl(5iE5l?R߃ z0'>2,⫹D w-ف];w&/wf8N ĀM.&O 444w{Bvff.h=ݨma]v^?47D1]VU!EI!V-و kkE8F$A8,r泩1ͩdWlj8&S6Y}s1Vf?a_xj a'%s. hhY;U2xi ߲ꞑ*w/vS(^cF' 'K`$B4O]4J4C8S@ L=YuuLH?.I)eHJ4C>) T5u:=iߔUOVȣEH%4%폷'qŸ3BkBqf Whf|1Q%c1C5d7ud'3~?%4@K@1i NIv udթ˙\;#O.񜒓N>x{+= nf]N]@4&~:4Gis\o{qo0 CwЇ?!*w wZ3*[a$q؏CrӿOsLGӡo1NXʘ D7o7=rowIDAT%~tȲW^2렬`t`FWޱ` Q.C M0 6@Y!7b߸\gğjhs??ܳ2R=;s_cvof˗/G<g I$qȲ@e64KJjSe #HqJbXB ̘frKTyٶteuJLljal/^Τ)"jRvusН:x'31&P*M A`$0&P* L$AH&cG{%z xvU՛*l 8S)23"RUVVAI@ii6*JhÊN439'y~˥| 8qiWכSA[Bd2#`:cA(Lr% pQy41E 0 @(rQLnaLdkIzތUUUL$ ɵi铮@z>Hv+V-tTQ^iz>u{,zuUGV=0;yӵfב_$bq1$tJD"Axh4=,x<< a ҥK-&8!L%,*+++ոB@ -}>ZCcHn2hŝMzmɚxnap`7HOD*э ,5D7^q!͌M|e5@Ad2) (cxdeIMY^@1tLuֱX,8$Ijz #L&u'"!+ĎVdgDd9@kk7`̶s Y(v4|TގJw24j:e_YV6*h<AjdY=A`spx I Ǔ$ 1RuEEӿC/̗'@ Չ3GGGmg|dR7AeA$l/h\q cpFk#:qXY09ّܴ:DQ&;1F ,="Kxnnnv\\@S؉tal9qv8{W'%ҤOZ#c 4eƘ9{fP^0Tn*))ṮyNܡ,k6$`ܸ)r&'Rvҗ's537XzHVE\Bԣ7xEԚYБ1=Ʋ\;}LeN_1Vz zLv!jdY&e6Oic_1Rz_K~e_b\$[nrMZ֯K|UUUu|7.?}OQdy6ĸg|8Ѧxl.y+f Zo'qY (s#3rҟ̯'*rcf3eK(뫬v}&,+F8ẌU1ͨU6𹌄oʓЖ[nyCz< >VUչ17H,0NiK7K~B|ιLD_q^zɺ'yi,dMg?W%1xϾZ(Fæefrҍ9;*7$@{fq-fJo +$F@$Y1 1ƕY?}ۯowÏQWZp ڙ= R+7NpY4}YõSvʭހW4tc\1 vXO>)s-7?16r)an5skRߪa'$7)`0hzBx uv3}W$a,126 @6ٵw:+В^yp#<|65͖fǔk Y-YifV8i$,ʩF Hlfyu7#2+ʗ@j)dRO7r]Ϲ!ENeQvn7{zJI3gf3R1lN:pMdC8ܛqIV}3w_3kgxnF|eݮ%Ofw ~po[Au4eR(g'Gmgsh k"i̮xI\ku #S|< yY u%C.lĸIE1 @:5sB:UɵJGee6*n'oVhfXh.H8|n^Sx(\Z.h(0v& Lz)Nl \a&gpr3UW%2Nax^_ͭj~ o5^?bn6;()Y޹ QtCW>HySc31^L-afx4.dP >_1X옦4&=~Ѧ4MRmzMBKvM'I$HcP3sB "|q#?xhe_>q0OnsJm8l+Im)"^7AmHd}}&^!7h7b_N?J#XEXIJ=!K=VIBa wc~ "!@:Z6a]/k6Z+ZSږ |R;2%KDRpz}RĎ1)=i Ͱ>'Yr\iԓR _qW[ P jBʱGOBkJ ;RzXak-p|>~Ϫoʻ 6\X v^Di( C|N;wlm~(PZo"\q 8!767v+;PA _ġvx~6%ת1u"0a:PQnkcRa K[,y ynj]HuxhX8jr 1I=SK93UNH  [$\{nDi~ZwPH)%Ni3۳"[6ePHmS^ZX3eܧ4~@F$J)qOk>r&jݏ5\C;(j鞽KbR B!B!B!B!B!B!B!B!rƙ|P}IENDB`snappy-0.3.7/data/icons/48x48/000077500000000000000000000000001213407343700156625ustar00rootroot00000000000000snappy-0.3.7/data/icons/48x48/Makefile.am000066400000000000000000000001401213407343700177110ustar00rootroot00000000000000icondir = $(datadir)/icons/hicolor/48x48/apps icon_DATA = snappy.png EXTRA_DIST = $(icon_DATA) snappy-0.3.7/data/icons/48x48/snappy.png000066400000000000000000000050751213407343700177110ustar00rootroot00000000000000PNG  IHDR00WsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org< IDAThYYl\rgg`Lb JBj*)*KUU"/*QԾڪT(BT Ji BXl,N8 Ix<۽߇ %CKxh>Y..>i }̻`32Ӄ-'~Ά*̅qI2 Dd 7R|"nQ,'vg_yɞ1yxC#i1صF(<=}8`-1!bA5ydV'Gq<{,g)Ϋܞ\+B5!BCD@Dp93i99rb6ϛ׋`-D{ "sȪ3`"]y0ZG9RDZbŊ׋;q&G9&I4 :.ȑU׫3&B.jDf%3cll v >k}+'6iDQ_zn2d `4;}_sFxv"I}l{;)Z!#aKTDMoLxo z']wu7 Vj@r@ZGp`#gûPRyX"oBWհbC*ⶋj>B1MB]o炛G7{!&i03|.b. #qqFC<̌bX 8h~m2$>Nַ.<_.|"(.ʀLB֮]x17ŠRXX}Ndx9ܔ̙|ҷ[6 >g٩q m#;_yf}#.ՔfLp[@&20OIJ =s=9NC9&901Q~&zCH& "Z &.4i >yq80>>3`GЁ,qĢVn7 / =h6Anz)  aF&Ad8vRmAwnN;i;0~|;4x "΂q?k]4Ayf,#"wmC4eѲJhY81 i&w/1фR6! C8\$GLF#ωvl'^AX,h]@(@D`ɋ7f4jn~ gp"/caԙXN}~kBaXD'F!`kj4;qnFyde#C|t0 oJ;ZM1r+dW9SCPj$6"[}o5j_9@VX wmAP1=؝Q2Օ7~m3! nKA" ŸqQ7v܊Dj)}΅x=6 P^qSW:]:=g^E*vR* Z/ #}c`-w?g5_'n³˒/%h(S P@Aem&4_^rS[KLв#}cPzs^_g;ga06m@Օk^saD;)苗ͷ쨅0) bbfH,J+e0R`C0 0-+< RJ(D+*e/8 `NG5ʕ+=kmX,F11cL9Yk"DD[kiUMQ^(cLo @)'yr9^qfymcLLke昵֊VJUmffֲRJQJAZcj:S}Է `f2"R snappy-0.3.7/data/media-actions-start.svg000066400000000000000000000026371213407343700203510ustar00rootroot00000000000000 snappy-0.3.7/data/mpris.xml000066400000000000000000000075221213407343700156320ustar00rootroot00000000000000 snappy-0.3.7/data/snappy.desktop000066400000000000000000000043421213407343700166600ustar00rootroot00000000000000[Desktop Entry] Name=Movie Player Comment=Play movies and songs Exec=snappy %U Icon=snappy Terminal=false Type=Application Categories=GTK;GNOME;AudioVideo;Player;Video; X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=snappy X-GNOME-Bugzilla-Component=ui X-GNOME-Bugzilla-Version=3.0.1 StartupNotify=true MimeType=application/mxf;application/ogg;application/ram;application/sdp;application/smil;application/smil+xml;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/prs.sid;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-xm;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gpp;video/dv;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-ms-asf;video/x-ms-asx;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;x-content/video-dvd;x-content/video-vcd;x-content/video-svcd;x-scheme-handler/pnm;x-scheme-handler/mms;x-scheme-handler/net;x-scheme-handler/rtp;x-scheme-handler/rtsp;x-scheme-handler/mmsh;x-scheme-handler/uvox;x-scheme-handler/icy;x-scheme-handler/icyx; NoDisplay=true snappy-0.3.7/data/subtitles-active.svg000066400000000000000000000077131213407343700177700ustar00rootroot00000000000000 snappy-0.3.7/data/subtitles-inactive.svg000066400000000000000000000076371213407343700203240ustar00rootroot00000000000000 snappy-0.3.7/data/video-stream-toggle.png000066400000000000000000000112311213407343700203320ustar00rootroot00000000000000PNG  IHDRdd]sRGBbKGD̿ pHYs B(xtIME9IDATxy]W}?no_x2ꆘR %4)RVm%JYGT6m*U*!a  RYǞ3̼}{Iz=|o߅ ڠ ڠ ڠ ڠ ڠ ?F3v;.y H$bV^Ĥx8_K B&nsʠ:_. WN8Ozhqw0 %J&Q@, +\iȃG_"g!bE4Y,0OxO\_d 1J/>5m4YRVe e6|Y_Gy1a,3WFQaFz&pIrK-|ȡ} el$&[9(9ak*mfGU.mby9Clß\%}X)Z !)Q\@_{ح<[uYDP5^%o|( IrMO2 .(ɶ|UܣVLB\/^o ( NC?8x7W>Ttljxp Ϭ*7/ NE,:e< < E$Ow1syϛ)[(4$yh׊K wĨLJ@ fĬUޣsrȇS[>1 1;Gܲ+B">6[=m+f6k CʯP?7yC| s'wчKǸB?<{0h k05 skxrNiܶǼ%kQ,6pd(a!@tB^2|zx޷3$FEGH4"Q%X)s`S"K<ʓ ͖dࣗy#˙#ϼ. ?'܁NRWmq6o\,n.3ؤ(#R"O)65΋2qLK uykRfMayA4<\6y|C 5X= ޅ8`S$~zJB(&CG)^UFbS`3rhtzS"C?1dp̹`F7e6ߍs7`e|1ˈ7fA5#6ǡOM'kU5?L‘~ ™8TJ*R (>)i"E%.s P憎8OZV9RmyĮUaTHTl6w $ZK `6?umt#zXb!#yUee&"Gdt5 5ln:PLٜ]43e 4ӂRN%uNž]dVE$lg;K\%A2 = < (^:r A?>d0)hÑ$#؜gB /&ŅIf#RDRp|U%V.Zw '%W1P`;'` k,Q[*GX%A#m,3x)ggldʦe`3#H$$OfH; ϒda"-"Vy^[ 0^QQmpV"p#JI4pƒ' `K%(.N+̬4~}##m4ɡ{2 N %r$26^na6/` ~~Yh<)\Dj hGsqxۈ 9e`KȥofHYpHs]`g qH:$7$Ƃ2UX"G1bkMzV$ev]P,38@é $y~ )N?]],B% l__l0fOAbnݕ].ME![C|m0<_Y%^ d @jM@iȣFgs ЦѬA,qIHtЎCZ.׉#U/eF5A 6DG $KH\kgB'ׁe 8Sל!~l Aoaaxls$te,2i8 &Љk<_u}wٱ>ݿH?Lu>(-U4)t0:-Yc i$Q`~4rL%=~4Az FxiAu2d?j]ϊ2ȶ$iJX$- ۔%N^ª'M$OR$GANSR©iFm͏&aBU`{9 US+tLtxU_9g繤Ke$Ih Mr=}y@Ǹxlk"*6ŵ y 'ZMJ19*Y @e,<5 r1ZZEd݋Z՞#խjg(%~J_MVf+ BX" Ԥ 1OiVhLԭ Z ^` Sq,ՒZX6S*p,k>Gz)UwUeE&ŭ7kfBĈ+ E=k0DCaS4գ:AYӖnϽGA/lbѣ_xX74̑z{eUmYnGOyOZJ͍aO;(4no+r(^]֍#ٿz[ؼ?>$`6h6h6h6h~?cxٙ$IENDB`snappy-0.3.7/docs/000077500000000000000000000000001213407343700137675ustar00rootroot00000000000000snappy-0.3.7/docs/clutter_controls_layout000066400000000000000000000016671213407343700207260ustar00rootroot00000000000000layout management of snappy's clutter controls ---------------------------------------------- ui->control_box (fixed alignment bin) [ ui->control_bg main_box (vertical alignment box) [ ui->control_title info_box (horizontal alignment box) [ ui->control_play_toggle ui->pos_n_vol_box (vertical alignment box) [ ui->control_seekbar (clutter actor draw_progressbar()) middle_box (horizontal alignment box) [ volume_box (horizontal alignment box) [ ui->volume_low ui->vol_int (clutter actor draw_progressbar()) ui->volume_high ] ui->control_pos ] bottom_box (horizontal alignment box) [ ui->video_stream_toggle ui->audio_stream_toggle ] ] right_box (horizontal alignment box) [ ui->subtitle_toggle ui->fullscreen_button ] ] ] ] for more information read: http://docs.clutter-project.org/docs/clutter-cookbook/stable/layouts.html snappy-0.3.7/docs/keyboard_controls000066400000000000000000000013761213407343700174440ustar00rootroot00000000000000keyboard controls for snappy ---------------------------- spacebar - play/pause f - fullscreen/unfullscreen esc - close snappy q - close snappy up - seek 1 minute foward down - seek 1 minute back left - seek 10 seconds back right - seek 10 seconds foward 8 - mute/unmute 9 - turn volume up 0 - turn volume down < - play previous > - play next c - show/hide visual controls v - toggle subtitles # - cycle through available audio streams _ - cycle through available video streams j - cycle through available subtitle streams r - rotate video . - frame step foward , - frame step backwards snappy-0.3.7/snappy.doap000066400000000000000000000022661213407343700152240ustar00rootroot00000000000000 snappy Powerful media player with a minimalistic interface snappy is an open source media player that gathers the power and flexibility of gstreamer inside the comfort of a minimalistic clutter interface. Luis de Bethencourt luisbg snappy-0.3.7/src/000077500000000000000000000000001213407343700136265ustar00rootroot00000000000000snappy-0.3.7/src/Makefile.am000066400000000000000000000011321213407343700156570ustar00rootroot00000000000000NULL = public_headers = \ utils.h \ user_interface.h \ dlna.h \ gst_engine.h \ screensaver.h c_sources = \ utils.c \ user_interface.c \ dlna.c \ gst_engine.c \ screensaver.c \ snappy.c CLEANFILES = bin_PROGRAMS = snappy snappy_SOURCES = $(c_sources) snappy_CFLAGS = $(CLUTTER_CFLAGS) $(GST_CFLAGS) $(CLUTTER_GST_CFLAGS) $(CLUTTER_GTK_CFLAGS) $(GTK_CFLAGS) $(GIO_CFLAGS) $(XTEST_CFLAGS) -DSNAPPY_DATA_DIR="\"$(pkgdatadir)\"" snappy_LDADD = $(GST_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GST_LIBS) $(CLUTTER_GTK_LIBS) $(GTK_LIBS) $(GIO_LIBS) $(XTEST_LIBS) noinst_HEADERS = $(public_headers) snappy-0.3.7/src/dlna.c000066400000000000000000000423401213407343700147130ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef ENABLE_DBUS #include #include #include "dlna.h" const char *mpris_introspection_xml = "" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " ""; /* for now */ static const GDBusInterfaceVTable interface_vtable = { (GDBusInterfaceMethodCallFunc) handle_method_call, (GDBusInterfaceGetPropertyFunc) handle_get_property, (GDBusInterfaceSetPropertyFunc) handle_set_property }; static const GDBusInterfaceVTable root_vtable = { (GDBusInterfaceMethodCallFunc) handle_root_method_call, (GDBusInterfaceGetPropertyFunc) get_root_property, NULL }; static GDBusNodeInfo *introspection_data = NULL; void my_object_change_uri (SnappyMP * myobj, gchar * uri) { if (myobj != NULL) myobj->uri = uri; engine_open_uri (myobj->engine, uri); interface_load_uri (myobj->ui, uri); engine_play (myobj->engine); } static void handle_result (GDBusMethodInvocation * invocation, gboolean ret, GError * error) { if (ret) { g_dbus_method_invocation_return_value (invocation, NULL); } else { if (error != NULL) { g_print ("DLNA returning error: %s", error->message); g_dbus_method_invocation_return_gerror (invocation, error); g_error_free (error); } else { g_print ("DLNA returning unknown error"); g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Unknown error"); } } } void handle_method_call (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * method_name, GVariant * parameters, GDBusMethodInvocation * invocation, SnappyMP * myobj) { gboolean ret = TRUE; GError *error = NULL; if (g_strcmp0 (object_path, MPRIS_OBJECT_NAME) != 0 || g_strcmp0 (interface_name, MPRIS_PLAYER_INTERFACE) != 0) { g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Method %s.%s not supported", interface_name, method_name); return; } if (g_strcmp0 (method_name, "OpenUri") == 0) { gchar *uri; // g_print ("openUri.. uri: %s\n", uri); g_variant_get (parameters, "(s)", &uri); my_object_change_uri (myobj, uri); g_dbus_method_invocation_return_value (invocation, NULL); } else if (g_strcmp0 (method_name, "Next") == 0) { /// ToDo: next track call handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Play") == 0) { engine_play (myobj->engine); handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Pause") == 0) { change_state (myobj->engine, "Paused"); handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Stop") == 0) { engine_stop (myobj->engine); handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Seek") == 0) { gint64 offset, position; gfloat relative; g_variant_get (parameters, "(x)", &offset); relative = offset / 100000000.0; position = myobj->engine->media_duration * relative; // g_print ("offset: %ld relative: %f", offset, relative); engine_seek (myobj->engine, position, FALSE); handle_result (invocation, ret, error); } } GVariant * handle_get_property (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * property_name, GError ** error, gpointer user_data) { GVariant *ret; SnappyMP *myobj = user_data; ret = NULL; if (g_strcmp0 (property_name, "Name") == 0) { ret = g_variant_new_string (myobj->name ? myobj->name : "snappy"); } else if (g_strcmp0 (property_name, "PlaybackStatus") == 0) { ret = g_variant_new_string ("Paused"); } else if (g_strcmp0 (property_name, "LoopStatus") == 0) { ret = g_variant_new_string ("Paused"); } else if (g_strcmp0 (property_name, "Rate") == 0) { ret = g_variant_new_double (0); } else if (g_strcmp0 (property_name, "Shuffle") == 0) { ret = g_variant_new_boolean (FALSE); } else if (g_strcmp0 (property_name, "Metadata") == 0) { ret = g_variant_new_array (G_VARIANT_TYPE_VARDICT, NULL, 0); } else if (g_strcmp0 (property_name, "Volume") == 0) { ret = g_variant_new_double (0); } else if (g_strcmp0 (property_name, "Position") == 0) { ret = g_variant_new_double (0); } else if (g_strcmp0 (property_name, "MinimumRate") == 0) { ret = g_variant_new_double (0); } else if (g_strcmp0 (property_name, "MaximumRate") == 0) { ret = g_variant_new_double (0); } else if (g_strcmp0 (property_name, "CanGoNext") == 0) { ret = g_variant_new_boolean (TRUE); } else if (g_strcmp0 (property_name, "CanGoPrevious") == 0) { ret = g_variant_new_boolean (FALSE); } else if (g_strcmp0 (property_name, "CanPlay") == 0) { ret = g_variant_new_boolean (TRUE); } else if (g_strcmp0 (property_name, "CanPause") == 0) { ret = g_variant_new_boolean (TRUE); } else if (g_strcmp0 (property_name, "CanSeek") == 0) { ret = g_variant_new_boolean (TRUE); } else if (g_strcmp0 (property_name, "CanControl") == 0) { ret = g_variant_new_boolean (TRUE); } else if (g_strcmp0 (property_name, "Identity") == 0) { ret = g_variant_new_string ("snappy"); } else if (g_strcmp0 (property_name, "SupportedUriSchemes") == 0) { /* not planning to support this seriously */ const char *fake_supported_schemes[] = { "file", "http", "cdda", "smb", "sftp", NULL }; return g_variant_new_strv (fake_supported_schemes, -1); } else if (g_strcmp0 (property_name, "SupportedMimeTypes") == 0) { /* nor this */ const char *fake_supported_mimetypes[] = { "application/ogg", "audio/x-vorbis+ogg", "audio/x-flac", "audio/mpeg", "video/mpeg", "video/quicktime", "video/x-ms-asf", "video/x-msvideo", "video/ogg", "audio/ogg", "application/annodex", "video/annodex", "video/x-matroska", "audio/x-matroska", "video/x-theora+ogg", NULL }; return g_variant_new_strv (fake_supported_mimetypes, -1); } return ret; } gboolean handle_set_property (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * property_name, GVariant * value, GError ** error, gpointer user_data) { SnappyMP *myobj = user_data; if (g_strcmp0 (property_name, "Name") == 0) { if (value != NULL) myobj->name = g_strdup (g_variant_get_string (value, NULL)); } else if (g_strcmp0 (property_name, "Volume") == 0) { gdouble level; level = g_variant_get_double (value); engine_volume (myobj->engine, level); } return TRUE; } void handle_root_method_call (GDBusConnection * connection, const char *sender, const char *object_path, const char *interface_name, const char *method_name, GVariant * parameters, GDBusMethodInvocation * invocation, SnappyMP * mp) { if (g_strcmp0 (object_path, MPRIS_OBJECT_NAME) != 0 || g_strcmp0 (interface_name, MPRIS_ROOT_INTERFACE) != 0) { g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Method %s.%s not supported", interface_name, method_name); return; } if (g_strcmp0 (method_name, "Raise") == 0) { g_dbus_method_invocation_return_value (invocation, NULL); } else if (g_strcmp0 (method_name, "Quit") == 0) { g_dbus_method_invocation_return_value (invocation, NULL); } else { g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Method %s.%s not supported", interface_name, method_name); } } GVariant * get_root_property (GDBusConnection * connection, const char *sender, const char *object_path, const char *interface_name, const char *property_name, GError ** error, SnappyMP * mp) { if (g_strcmp0 (object_path, MPRIS_OBJECT_NAME) != 0 || g_strcmp0 (interface_name, MPRIS_ROOT_INTERFACE) != 0) { g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Property %s.%s not supported", interface_name, property_name); return NULL; } if (g_strcmp0 (property_name, "CanQuit") == 0) { return g_variant_new_boolean (FALSE); } else if (g_strcmp0 (property_name, "CanRaise") == 0) { return g_variant_new_boolean (FALSE); } else if (g_strcmp0 (property_name, "HasTrackList") == 0) { return g_variant_new_boolean (FALSE); } else if (g_strcmp0 (property_name, "Identity") == 0) { return g_variant_new_string ("snappy"); } else if (g_strcmp0 (property_name, "DesktopEntry") == 0) { return g_variant_new_string ("snappy"); } else if (g_strcmp0 (property_name, "SupportedUriSchemes") == 0) { /* not planning to support this seriously */ const char *fake_supported_schemes[] = { "file", "http", "cdda", "smb", "sftp", NULL }; return g_variant_new_strv (fake_supported_schemes, -1); } else if (g_strcmp0 (property_name, "SupportedMimeTypes") == 0) { /* nor this */ const char *fake_supported_mimetypes[] = { "video/mpeg", "video/quicktime", "video/x-ms-asf", "video/x-msvideo", "video/ogg", "audio/ogg", "application/annodex", "video/annodex", "application/ogg", "audio/x-vorbis+ogg", "audio/x-flac", "audio/mpeg", "video/x-matroska", "audio/x-matroska", "video/x-theora+ogg", NULL }; return g_variant_new_strv (fake_supported_mimetypes, -1); } g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Property %s.%s not supported", interface_name, property_name); return NULL; } static void send_property_change (SnappyMP * myobj, GParamSpec * pspec, GDBusConnection * connection) { GVariantBuilder *builder; GVariantBuilder *invalidated_builder; builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); if (g_strcmp0 (pspec->name, "name") == 0) g_variant_builder_add (builder, "{sv}", "Name", g_variant_new_string (myobj->name ? myobj->name : "")); g_dbus_connection_emit_signal (connection, NULL, "org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "PropertiesChanged", g_variant_new ("(sa{sv}as)", "org.mpris.MediaPlayer2", builder, invalidated_builder), NULL); } static void on_name_acquired (GDBusConnection * connection, const gchar * name, gpointer user_data) { // g_print ("DLNA MediaPlayer name acquired.\n"); } static void on_name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data) { exit (1); } gboolean load_dlna (SnappyMP * mp) { guint owner_id, player_id, root_id; GError *error = NULL; GDBusInterfaceInfo *ifaceinfo; GDBusConnection *connection; g_type_init (); connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); /* Build the introspection data structures from the XML */ introspection_data = g_dbus_node_info_new_for_xml (mpris_introspection_xml, NULL); g_assert (introspection_data != NULL); /* register media player interface */ ifaceinfo = g_dbus_node_info_lookup_interface (introspection_data, MPRIS_PLAYER_INTERFACE); mp->player_id = g_dbus_connection_register_object (connection, MPRIS_OBJECT_NAME, ifaceinfo, &interface_vtable, mp, NULL, &error); /* register root interface */ ifaceinfo = g_dbus_node_info_lookup_interface (introspection_data, MPRIS_ROOT_INTERFACE); mp->root_id = g_dbus_connection_register_object (connection, MPRIS_OBJECT_NAME, ifaceinfo, &root_vtable, NULL, NULL, &error); if (error != NULL) { g_warning ("unable to register MPRIS root interface: %s", error->message); g_error_free (error); } mp->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.mpris.MediaPlayer2.snappy", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, (GBusNameAcquiredCallback) on_name_acquired, (GBusNameLostCallback) on_name_lost, mp, NULL); g_assert (mp->owner_id > 0); mp->name = g_strdup ("snappy"); return TRUE; } gboolean close_dlna (SnappyMP * mp) { g_bus_unown_name (mp->owner_id); g_dbus_node_info_unref (introspection_data); g_free (mp->name); return TRUE; } #endif snappy-0.3.7/src/dlna.h000066400000000000000000000063151213407343700147220ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifndef __DLNA_H__ #define __DLNA_H__ #include #include #include "gst_engine.h" #include "user_interface.h" G_BEGIN_DECLS #define MPRIS_BUS_NAME_PREFIX "org.mpris.MediaPlayer2" #define MPRIS_OBJECT_NAME "/org/mpris/MediaPlayer2" #define MPRIS_ROOT_INTERFACE "org.mpris.MediaPlayer2" #define MPRIS_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player" #define MPRIS_TRACKLIST_INTERFACE "org.mpris.MediaPlayer2.TrackList" #define MPRIS_PLAYLISTS_INTERFACE "org.mpris.MediaPlayer2.Playlists" typedef struct _SnappyMP SnappyMP; struct _SnappyMP { gchar *name; GDBusConnection *connection; GDBusNodeInfo *node_info; guint name_own_id; guint root_id; guint player_id; guint playlists_id; guint owner_id; int playlist_count; GHashTable *player_property_changes; GHashTable *playlist_property_changes; guint property_emit_id; gint64 last_elapsed; gchar *uri; GstEngine *engine; UserInterface *ui; }; enum { PROP_0, PROP_COUNT, PROP_NAME }; enum { OPEN_URI, LAST_SIGNAL }; static guint mediaplayer_signals[LAST_SIGNAL] = { 0 }; // Declaration of non-static functions gboolean load_dlna (SnappyMP * mp_obj); gboolean close_dlna (SnappyMP * mp_obj); void handle_method_call (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * method_name, GVariant * parameters, GDBusMethodInvocation * invocation, SnappyMP * myobj); GVariant *handle_get_property (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * property_name, GError ** error, gpointer user_data); gboolean handle_set_property (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * property_name, GVariant * value, GError ** error, gpointer user_data); void handle_root_method_call (GDBusConnection * connection, const char *sender, const char *object_path, const char *interface_name, const char *method_name, GVariant * parameters, GDBusMethodInvocation * invocation, SnappyMP * mp); GVariant *get_root_property (GDBusConnection * connection, const char *sender, const char *object_path, const char *interface_name, const char *property_name, GError ** error, SnappyMP * mp); G_END_DECLS #endif /* __DLNA_H__ */ snappy-0.3.7/src/gst_engine.c000066400000000000000000000652331213407343700161250ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #include #include #include /* for S_IRUSR | S_IWUSR | S_IXUSR */ #include "user_interface.h" #include "gst_engine.h" #include "utils.h" #define SAVE_POSITION_MIN_DURATION 300 * 1000 // don't save >5 minute files #define SAVE_POSITION_THRESHOLD 0.05 // percentage threshold #define RECENTLY_VIEWED_MAX 50 // GstPlayFlags flags from playbin. It is the policy of GStreamer to // not publicly expose element-specific enums. That's why this // GstPlayFlags enum has been copied here. typedef enum { GST_PLAY_FLAG_VIDEO = 0x00000001, GST_PLAY_FLAG_AUDIO = 0x00000002, GST_PLAY_FLAG_TEXT = 0x00000004, GST_PLAY_FLAG_VIS = 0x00000008, GST_PLAY_FLAG_SOFT_VOLUME = 0x00000010, GST_PLAY_FLAG_NATIVE_AUDIO = 0x00000020, GST_PLAY_FLAG_NATIVE_VIDEO = 0x00000040, GST_PLAY_FLAG_DOWNLOAD = 0x00000080, GST_PLAY_FLAG_BUFFERING = 0x000000100, GST_PLAY_FLAG_DEINTERLACE = 0x000000200, GST_PLAY_FLAG_SOFT_COLORBALANCE = 0x000000400 } GstPlayFlags; // Declaration of static functions gboolean add_uri_to_history (gchar * uri); gboolean add_uri_unfinished_playback (GstEngine * engine, gchar * uri, gint64 position); gboolean discover (GstEngine * engine, gchar * uri); static void handle_element_message (GstEngine * engine, GstMessage * msg); gboolean is_stream_seakable (GstEngine * engine); gint64 is_uri_unfinished_playback (GstEngine * engine, gchar * uri); static void print_tag (const GstTagList * list, const gchar * tag, gpointer unused); void remove_uri_unfinished_playback (GstEngine * engine, gchar * uri); void stream_done (GstEngine * engine, UserInterface * ui); static void write_key_file_to_file (GKeyFile * keyfile, const char *path); /* -------------------- static functions --------------------- */ /* Add URI to recently viewed list */ gboolean add_uri_to_history (gchar * uri) { gboolean ret; const gchar *config_dir; gchar *path, *clean_uri; gchar **history_keys; gsize length; GKeyFile *keyfile; GKeyFileFlags flags; keyfile = g_key_file_new (); flags = G_KEY_FILE_KEEP_COMMENTS; /* Config file path */ config_dir = g_get_user_config_dir (); path = g_strdup_printf ("%s/snappy/history", config_dir); /* Keynames can't include brackets */ clean_uri = clean_brackets_in_uri (uri); if (g_key_file_load_from_file (keyfile, path, flags, NULL)) { /* Set uri in history */ if (g_key_file_has_group (keyfile, "history")) { if (!g_key_file_has_key (keyfile, "history", clean_uri, NULL)) { /* Uri is not already in history */ history_keys = g_key_file_get_keys (keyfile, "history", &length, NULL); if (length >= RECENTLY_VIEWED_MAX) { /* Remove first uri of the list */ g_key_file_remove_key (keyfile, "history", history_keys[0], NULL); } } } else { /* If group "history" doesn't exist create it and populate it */ g_key_file_set_boolean (keyfile, "history", clean_uri, TRUE); } /* g_get_real_time () is not available until glib 2.28.0 */ #if GLIB_CHECK_VERSION (2, 28, 0) g_key_file_set_int64 (keyfile, "history", clean_uri, g_get_real_time ()); #else { GTimeVal time; g_get_current_time (&time); g_key_file_set_int64 (keyfile, "history", clean_uri, (gint64) time.tv_sec); } #endif /* Save gkeyfile to a file */ write_key_file_to_file (keyfile, path); g_free (path); ret = TRUE; } else { ret = FALSE; } return ret; } /* Add URI's last playback position to the unfinished list */ gboolean add_uri_unfinished_playback (GstEngine * engine, gchar * uri, gint64 position) { guint hash_key; gint64 duration; const gchar *config_dir; gchar *path, *key; GKeyFile *keyfile; GKeyFileFlags flags; duration = engine->media_duration; if (duration < SAVE_POSITION_MIN_DURATION || (duration - position) < (duration * SAVE_POSITION_THRESHOLD) || (position < duration * SAVE_POSITION_THRESHOLD)) { /* Remove in case position is already stored and close */ remove_uri_unfinished_playback (engine, uri); return FALSE; } /* New keyfile with uri as hash key */ keyfile = g_key_file_new (); flags = G_KEY_FILE_KEEP_COMMENTS; hash_key = g_str_hash (uri); key = g_strdup_printf ("%d", hash_key); /* Config file path */ config_dir = g_get_user_config_dir (); path = g_strdup_printf ("%s/snappy/history", config_dir); /* Store uri and position in key file */ g_key_file_load_from_file (keyfile, path, flags, NULL); g_key_file_set_int64 (keyfile, "unfinished", key, position); /* Save gkeyfile to a file, if file doesn't exist it creates a new one */ write_key_file_to_file (keyfile, path); g_free (path); return TRUE; } /* Discover URI's properties: duration and dimensions */ gboolean discover (GstEngine * engine, gchar * uri) { gint timeout = 10; GstDiscoverer *dc; GstDiscovererInfo *info; GstDiscovererStreamInfo *s_info; GstDiscovererVideoInfo *v_info; GError *error = NULL; GList *list; GstPlayFlags flags; /* new GST Discoverer */ dc = gst_discoverer_new (timeout * GST_SECOND, &error); if (G_UNLIKELY (error)) { GST_WARNING ("Error in GST Discoverer initializing: %s\n", error->message); g_error_free (error); return FALSE; } /* Discover URI */ info = gst_discoverer_discover_uri (dc, uri, &error); if (G_UNLIKELY (error)) { GST_WARNING ("Error discovering URI: %s\n", error->message); g_error_free (error); return FALSE; } /* Check if it has a video stream */ list = gst_discoverer_info_get_video_streams (info); engine->has_video = (g_list_length (list) > 0); gst_discoverer_stream_info_list_free (list); /* Check if it has an audio stream */ list = gst_discoverer_info_get_audio_streams (info); engine->has_audio = (g_list_length (list) > 0); gst_discoverer_stream_info_list_free (list); /* If it has any stream, get duration */ if (engine->has_video || engine->has_audio) engine->media_duration = gst_discoverer_info_get_duration (info); GST_DEBUG ("Found video %d, audio %d", engine->has_video, engine->has_audio); /* If it has video stream, get dimensions */ if (engine->has_video) { list = gst_discoverer_info_get_video_streams (info); v_info = (GstDiscovererVideoInfo *) list->data; engine->media_width = gst_discoverer_video_info_get_width (v_info); GST_DEBUG ("video width: %d", engine->media_width); engine->media_height = gst_discoverer_video_info_get_height (v_info); GST_DEBUG ("video height: %d", engine->media_height); } else { /* If only audio stream, play visualizations */ g_object_get (G_OBJECT (engine->player), "flags", &flags, NULL); g_object_set (G_OBJECT (engine->player), "flags", flags | GST_PLAY_FLAG_VIS, NULL); } gst_discoverer_info_unref (info); return TRUE; } /* Handle GST_ELEMENT_MESSAGEs */ static void handle_element_message (GstEngine * engine, GstMessage * msg) { GstNavigationMessageType nav_msg_type = gst_navigation_message_get_type (msg); switch (nav_msg_type) { case GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED:{ GST_DEBUG ("Navigation message commands changed"); if (is_stream_seakable (engine)) { update_media_duration (engine); } break; } default:{ break; } } } /* Query if the current stream is seakable */ gboolean is_stream_seakable (GstEngine * engine) { GstQuery *query; gboolean res; query = gst_query_new_seeking (GST_FORMAT_TIME); if (gst_element_query (engine->player, query)) { gst_query_parse_seeking (query, NULL, &res, NULL, NULL); GST_DEBUG ("seeking query says the stream is %s seekable", (res) ? "" : " not"); } else { GST_DEBUG ("seeking query failed"); } gst_query_unref (query); return res; } /* Check if URI is in the unfinished playback list */ gint64 is_uri_unfinished_playback (GstEngine * engine, gchar * uri) { guint hash_key; gint64 position = -1; const gchar *config_dir; gchar *path, *key; GKeyFile *keyfile; GKeyFileFlags flags; keyfile = g_key_file_new (); flags = G_KEY_FILE_KEEP_COMMENTS; hash_key = g_str_hash (uri); key = g_strdup_printf ("%d", hash_key); /* Config file path */ config_dir = g_get_user_config_dir (); path = g_strdup_printf ("%s/snappy/history", config_dir); /* If URI hash key is in the list, load position */ if (g_key_file_load_from_file (keyfile, path, flags, NULL)) if (g_key_file_has_group (keyfile, "unfinished")) if (g_key_file_has_key (keyfile, "unfinished", key, NULL)) position = g_key_file_get_int64 (keyfile, "unfinished", key, NULL); g_key_file_free (keyfile); g_free (path); return position; } /* Print message tags from elements */ static void print_tag (const GstTagList * list, const gchar * tag, gpointer unused) { gint i, count; count = gst_tag_list_get_tag_size (list, tag); for (i = 0; i < count; i++) { gchar *str; if (gst_tag_get_type (tag) == G_TYPE_STRING) { if (!gst_tag_list_get_string_index (list, tag, i, &str)) g_assert_not_reached (); } else { str = g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); } if (i == 0) { g_print (" %15s: %s\n", gst_tag_get_nick (tag), str); } else { g_print (" : %s\n", str); } g_free (str); } } /* Remove URI from unfinished playback list */ void remove_uri_unfinished_playback (GstEngine * engine, gchar * uri) { guint hash_key; const gchar *config_dir; gchar *path, *data, *key; GError *error = NULL; GKeyFile *keyfile; GKeyFileFlags flags; keyfile = g_key_file_new (); flags = G_KEY_FILE_KEEP_COMMENTS; hash_key = g_str_hash (uri); key = g_strdup_printf ("%d", hash_key); /* Config file path */ config_dir = g_get_user_config_dir (); /* Self config directory, i.e. .config/snappy/ */ struct stat st_self; if (0 != stat (g_strdup_printf ("%s/snappy", config_dir), &st_self)) { if (0 != mkdir (g_strdup_printf ("%s/snappy", config_dir), 0777)) perror ("Failed to create ~/.config/snappy/ directory"); } else if (!S_ISDIR (st_self.st_mode)) { errno = ENOTDIR; perror ("~/config/snappy/ already exists"); } /* History file */ path = g_strdup_printf ("%s/snappy/history", config_dir); /* Remove key from history file */ if (g_key_file_load_from_file (keyfile, path, flags, NULL)) g_key_file_remove_key (keyfile, "unfinished", key, NULL); /* Save gkeyfile to a file */ data = g_key_file_to_data (keyfile, NULL, NULL); g_file_set_contents (path, data, strlen (data), &error); if (error != NULL) { GST_WARNING ("Failed to write history file to %s: %s", path, error->message); g_error_free (error); } g_free (data); g_free (path); return; } /* When Stream or segment is done play next or loop */ void stream_done (GstEngine * engine, UserInterface * ui) { /* When URI is done or looping remove from unfinished list */ remove_uri_unfinished_playback (engine, engine->uri); if (engine->loop && (interface_is_it_last (ui))) { engine_seek (engine, 0, TRUE); } else { interface_play_next_or_prev (ui, TRUE); } } static void write_key_file_to_file (GKeyFile * keyfile, const char *path) { gchar *data, *dir; GError *error = NULL; dir = g_path_get_dirname (path); g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); g_free (dir); data = g_key_file_to_data (keyfile, NULL, NULL); g_file_set_contents (path, data, strlen (data), &error); if (error != NULL) { GST_WARNING ("Failed to write history file to %s: %s", path, error->message); g_error_free (error); } g_free (data); } /* -------------------- non-static functions --------------------- */ /* Add URI to uninished list */ gboolean add_uri_unfinished (GstEngine * engine) { gboolean ret; gint64 position; if (engine->uri) { position = query_position (engine); ret = add_uri_unfinished_playback (engine, engine->uri, position); } return ret; } /* Check if playback is at End of Stream */ gboolean at_the_eos (GstEngine * engine) { gboolean ret = TRUE; gint64 position; position = query_position (engine); if (position < engine->media_duration) ret = FALSE; return ret; } /* Gstreamer pipeline bus call */ gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data) { UserInterface *ui = (UserInterface *) data; GstEngine *engine = ui->engine; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_STATE_CHANGED: { GstState old, new, pending; GST_DEBUG ("State changed"); gst_message_parse_state_changed (msg, &old, &new, &pending); if (new == GST_STATE_PLAYING) { gint streams; /* If loading file */ if (!engine->has_started) { gint64 position; /* Check if URI was left unfinished, if so seek to last position */ position = is_uri_unfinished_playback (engine, engine->uri); if (position != -1) { engine_seek (engine, position, TRUE); } if (!engine->secret) add_uri_to_history (engine->uri); else g_print ("Secret mode. Not saving uri in history.\n"); if (has_subtitles (engine)) ui->subtitles_available = TRUE; else ui->subtitles_available = FALSE; interface_update_controls (ui); engine->has_started = TRUE; } } break; } case GST_MESSAGE_TAG: { GstTagList *tags; GST_DEBUG ("Tag received"); if (ui->tags) { gst_message_parse_tag (msg, &tags); if (tags) { g_print ("%s\n", GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (msg)))); gst_tag_list_foreach (tags, print_tag, NULL); gst_tag_list_free (tags); tags = NULL; } } break; } case GST_MESSAGE_EOS: { GST_DEBUG ("End of stream"); stream_done (engine, ui); break; } case GST_MESSAGE_SEGMENT_DONE: { GST_DEBUG ("Segment done"); stream_done (engine, ui); break; } case GST_MESSAGE_STEP_DONE: { GST_DEBUG ("Step done"); engine->prev_done = TRUE; break; } case GST_MESSAGE_ASYNC_DONE: GST_DEBUG ("Async done"); engine->queries_blocked = FALSE; break; case GST_MESSAGE_DURATION: { GST_DEBUG ("Message duration received"); update_media_duration (engine); break; } case GST_MESSAGE_ELEMENT: { handle_element_message (engine, msg); break; } case GST_MESSAGE_WARNING: { /* Parse and share Gst Warning */ gchar *debug = NULL; GError *err = NULL; gst_message_parse_warning (msg, &err, &debug); if (err) { // If warning is missing plugins inform the user, if not display warning if (!check_missing_plugins_error (engine, msg)) { g_print ("Warning: %s", err->message); GST_DEBUG ("Warning: %s", err->message); } g_error_free (err); if (debug) { GST_DEBUG ("Debug details: %s", debug); g_free (debug); } } break; } case GST_MESSAGE_ERROR: { /* Parse and share Gst Error */ gchar *debug = NULL; GError *err = NULL; gst_message_parse_error (msg, &err, &debug); if (err) { g_print ("Error: %s\n", err->message); GST_DEBUG ("Error: %s", err->message); g_error_free (err); if (debug) { GST_DEBUG ("Debug details: %s", debug); g_free (debug); } } break; } default: break; } return TRUE; } /* Change pipeline state */ gboolean change_state (GstEngine * engine, gchar * state) { gboolean ok = TRUE; GstStateChangeReturn change; if (!g_strcmp0 (state, "Playing")) { change = gst_element_set_state (engine->player, GST_STATE_PLAYING); engine->playing = TRUE; engine->queries_blocked = FALSE; } else if (!g_strcmp0 (state, "Paused")) { change = gst_element_set_state (engine->player, GST_STATE_PAUSED); engine->playing = FALSE; engine->queries_blocked = FALSE; } else if (!g_strcmp0 (state, "Ready")) { change = gst_element_set_state (engine->player, GST_STATE_READY); engine->playing = FALSE; engine->media_duration = -1; engine->queries_blocked = TRUE; } else if (!g_strcmp0 (state, "Null")) { change = gst_element_set_state (engine->player, GST_STATE_NULL); engine->playing = FALSE; engine->media_duration = -1; engine->queries_blocked = TRUE; } if (change == GST_STATE_CHANGE_FAILURE) ok = FALSE; return ok; } gboolean check_missing_plugins_error (GstEngine * engine, GstMessage * msg) { gboolean error_src_is_decoder, error_src_is_missing_plugins; GError *err = NULL; gst_message_parse_warning (msg, &err, NULL); // Is the Error coming from uridecodebin? error_src_is_decoder = g_str_has_prefix (gst_object_get_name (msg->src), "uridecodebin"); // Is the error "Codec not found"? Then display verbose warning if (error_src_is_decoder && err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND) { g_print ("You are missing a GStreamer plugin needed to play this file.%s", "\nCheck your GStreamer installation.\n"); GST_DEBUG ("Warning: Codec not Found"); error_src_is_missing_plugins = TRUE; } else { error_src_is_missing_plugins = FALSE; } return error_src_is_missing_plugins; } /* Cycle through streams */ gboolean cycle_streams (GstEngine * engine, guint streamid) { gboolean last_stream = FALSE; gint current; gint streams; gchar *n; gchar *c; switch (streamid) { case STREAM_AUDIO: n = "n-audio"; c = "current-audio"; break; case STREAM_TEXT: n = "n-text"; c = "current-text"; break; case STREAM_VIDEO: n = "n-video"; c = "current-video"; break; } g_object_get (G_OBJECT (engine->player), n, &streams, NULL); g_object_get (G_OBJECT (engine->player), c, ¤t, NULL); if (current < (streams - 1)) { current++; } else { current = 0; last_stream = TRUE; } g_object_set (G_OBJECT (engine->player), c, current, NULL); return last_stream; } /* Init GstEngine variables */ gboolean engine_init (GstEngine * engine, GstElement * sink) { engine->playing = FALSE; engine->direction_foward = TRUE; engine->prev_done = TRUE; engine->has_started = FALSE; engine->has_video = FALSE; engine->has_audio = FALSE; engine->loop = FALSE; engine->secret = FALSE; engine->queries_blocked = TRUE; engine->media_width = 600; engine->media_height = 400; engine->media_duration = -1; engine->second = GST_SECOND; engine->uri = NULL; gchar *version_str; GST_DEBUG_CATEGORY_INIT (_snappy_gst_debug, "snappy", 0, "snappy media player"); /* Make playbin element */ engine->player = gst_element_factory_make ("playbin", "playbin"); if (engine->player == NULL) { g_print ("ERROR: Failed to create playbin element\n"); return FALSE; } /* Set Clutter texture as playbin's videos sink */ engine->sink = sink; g_object_set (G_OBJECT (engine->player), "video-sink", engine->sink, NULL); engine->bus = gst_pipeline_get_bus (GST_PIPELINE (engine->player)); engine->navigation = GST_NAVIGATION (gst_bin_get_by_interface (GST_BIN (engine->player), GST_TYPE_NAVIGATION)); return TRUE; } /* Load URI to engine */ void engine_load_uri (GstEngine * engine, gchar * uri) { engine->uri = uri; /* Loading a new URI means we haven't started playing this URI yet */ engine->has_started = FALSE; engine->queries_blocked = TRUE; if (uri) { discover (engine, uri); g_print ("Loading: %s\n", uri); g_object_set (G_OBJECT (engine->player), "uri", uri, NULL); } else { g_print ("No media set. %s\n", "You can drag and drop a file into snappy to play it."); } return; } /* Open Uri in engine */ void engine_open_uri (GstEngine * engine, gchar * uri) { /* Need to set back to Ready state so Playbin loads uri */ engine->uri = uri; g_print ("Open uri: %s\n", uri); gst_element_set_state (engine->player, GST_STATE_READY); g_object_set (G_OBJECT (engine->player), "uri", uri, NULL); discover (engine, uri); return; } /* Set to Playing */ gboolean engine_play (GstEngine * engine) { gboolean ok = TRUE; GstStateChangeReturn change; change = gst_element_set_state (engine->player, GST_STATE_PLAYING); engine->playing = TRUE; engine->queries_blocked = FALSE; if (change == GST_STATE_CHANGE_FAILURE) ok = FALSE; return ok; } /* Seek engine to position */ gboolean engine_seek (GstEngine * engine, gint64 position, gboolean accurate) { gboolean ok; GstFormat fmt = GST_FORMAT_TIME; GstSeekFlags flags; if (accurate) { flags = GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_ACCURATE; } else { flags = GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_KEY_UNIT; } ok = gst_element_seek_simple (engine->player, fmt, flags, position); engine->queries_blocked = TRUE; return ok; } /* Stop playback */ gboolean engine_stop (GstEngine * engine) { gboolean ok = TRUE; GstStateChangeReturn change; change = gst_element_set_state (engine->player, GST_STATE_READY); engine->playing = FALSE; engine->queries_blocked = TRUE; if (change == GST_STATE_CHANGE_FAILURE) ok = FALSE; return ok; } /* Set volume */ void engine_volume (GstEngine * engine, gdouble level) { g_object_set (G_OBJECT (engine->player), "volume", level, NULL); return; } /* Move one step foward or backwards */ gboolean frame_stepping (GstEngine * engine, gboolean foward) { gboolean ok; gint64 pos; gdouble rate; GstFormat fmt; /* Continue if previous frame step is done */ if (engine->prev_done) { engine->prev_done = FALSE; if (foward != engine->direction_foward) { /* Change of direction needed */ engine->direction_foward = foward; ok = gst_element_query_position (engine->player, GST_FORMAT_TIME, &pos); gst_element_get_state (engine->player, NULL, NULL, GST_SECOND); if (foward) rate = 1.0; else rate = -1.0; /* Seek with current position and reverse rate */ if (rate >= 0.0) { ok = gst_element_seek (engine->player, rate, fmt, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET, pos, GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE); } else { ok = gst_element_seek (engine->player, rate, fmt, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0), GST_SEEK_TYPE_SET, pos); } gst_element_get_state (engine->player, NULL, NULL, GST_SECOND); } /* Send new step event */ fmt = GST_FORMAT_BUFFERS; gst_element_send_event (engine->player, gst_event_new_step (fmt, 1, 1.0, TRUE, FALSE)); engine->queries_blocked = TRUE; } return ok; } /* Get recently viewed URIs */ gchar ** get_recently_viewed () { const gchar *config_dir; gchar *path; gchar **recent = NULL; gsize length; GKeyFile *keyfile; GKeyFileFlags flags; keyfile = g_key_file_new (); flags = G_KEY_FILE_KEEP_COMMENTS; /* Config file path */ config_dir = g_get_user_config_dir (); path = g_strdup_printf ("%s/snappy/history", config_dir); /* Get keys */ if (g_key_file_load_from_file (keyfile, path, flags, NULL)) if (g_key_file_has_group (keyfile, "history")) recent = g_key_file_get_keys (keyfile, "history", &length, NULL); return recent; } /* Check if the uri has subtitles */ gboolean has_subtitles (GstEngine * engine) { gint streams; gboolean ret; g_object_get (G_OBJECT (engine->player), "n-text", &streams, NULL); if (streams > 0) ret = TRUE; else ret = FALSE; return ret; } /* Get pipeline state */ GstState get_state (GstEngine * engine) { GstState state; gst_element_get_state (engine->player, &state, NULL, GST_SECOND); return state; } /* Query playback position */ gint64 query_position (GstEngine * engine) { gboolean ok; gint64 position; ok = gst_element_query_position (engine->player, GST_FORMAT_TIME, &position); if (!ok) position = 0; return position; } /* Set subtitle file */ void set_subtitle_uri (GstEngine * engine, gchar * suburi) { g_print ("Loading subtitles: %s\n"); g_object_set (G_OBJECT (engine->player), "suburi", suburi, NULL); return; } /* Toggle subtitles */ gboolean toggle_subtitles (GstEngine * engine) { gint flags; gboolean last_stream; gboolean sub_state; g_object_get (G_OBJECT (engine->player), "flags", &flags, NULL); sub_state = flags & (1 << 2); if (sub_state) { // If subtitles on, cycle streams and if last turn off last_stream = cycle_streams (engine, STREAM_TEXT); if (last_stream) { flags &= ~(1 << 2); g_object_set (G_OBJECT (engine->player), "flags", flags, NULL); } } else { // If subtitles off, turn them on flags |= (1 << 2); g_object_set (G_OBJECT (engine->player), "flags", flags, NULL); } g_object_get (G_OBJECT (engine->player), "flags", &flags, NULL); sub_state = flags & (1 << 2); return sub_state; } /* Update duration of URI streams */ gboolean update_media_duration (GstEngine * engine) { gboolean success = FALSE; if (gst_element_query_duration (engine->player, GST_FORMAT_TIME, &engine->media_duration)) { if (engine->media_duration != -1) { success = TRUE; } else { GST_DEBUG ("Could not get media's duration"); success = FALSE; } } return success; } snappy-0.3.7/src/gst_engine.h000066400000000000000000000052111213407343700161200ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifndef __GST_ENGINE_H__ #define __GST_ENGINE_H__ #include /* GStreamer Interfaces */ #include G_BEGIN_DECLS GST_DEBUG_CATEGORY_STATIC (_snappy_gst_debug); #define GST_CAT_DEFAULT _snappy_gst_debug typedef struct _GstEngine GstEngine; struct _GstEngine { gboolean playing, direction_foward, prev_done; gboolean has_started; gboolean has_video, has_audio; gboolean loop; gboolean secret; gboolean queries_blocked; guint media_width, media_height; gint64 media_duration; gint64 second; gchar *uri; GstElement *player; GstElement *sink; GstBus *bus; GstNavigation *navigation; }; // Declaration of non-static functions gboolean add_uri_unfinished (GstEngine * engine); gboolean at_the_eos (GstEngine * engine); gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data); gboolean change_state (GstEngine * engine, gchar * state); gboolean check_missing_plugins_error (GstEngine * engine, GstMessage * msg); gboolean cycle_streams (GstEngine * engine, guint streamid); gboolean engine_init (GstEngine * engine, GstElement * sink); void engine_load_uri (GstEngine * engine, gchar * uri); void engine_open_uri (GstEngine * engine, gchar * uri); gboolean engine_play (GstEngine * engine); gboolean engine_seek (GstEngine * engine, gint64 position, gboolean accurate); gboolean engine_stop (GstEngine * engine); void engine_volume (GstEngine * engine, gdouble level); gboolean frame_stepping (GstEngine * engine, gboolean foward); gchar **get_recently_viewed (); GstState get_state (GstEngine * engine); gboolean has_subtitles (GstEngine * engine); gint64 query_position (GstEngine * engine); void set_subtitle_uri (GstEngine * engine, gchar *suburi); gboolean toggle_subtitles (GstEngine * engine); gboolean update_media_duration (GstEngine * engine); G_END_DECLS #endif /* __GST_ENGINE_H__ */ snappy-0.3.7/src/screensaver.c000066400000000000000000000220351213407343700163140ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Sebastian Droege * * The screensaver code is heavily based on totem, which is * Copyright (C) 2004-2006 Bastien Nocera * Copyright © 2010 Christian Persch * Copyright © 2010 Carlos Garcia Campos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "screensaver.h" #ifdef HAVE_WIN32 #include #endif #ifdef HAVE_X11 #include #ifdef HAVE_XTEST #include #endif #else /* The DBus screensaver stuff needs X11 */ #ifdef ENABLE_DBUS #undef ENABLE_DBUS #endif #endif #ifdef ENABLE_DBUS #include #endif struct _ScreenSaver { ClutterStage *stage; gboolean disabled; #ifdef HAVE_X11 Window window; Display *display; #endif #ifdef ENABLE_DBUS GDBusProxy *gs_proxy; gboolean have_session_dbus; guint32 cookie; #endif #ifdef HAVE_X11 gint timeout; gint interval; gint prefer_blanking; gint allow_exposures; #ifdef HAVE_XTEST gint keycode1, keycode2; gint *keycode; gboolean have_xtest; #endif #endif }; #ifdef HAVE_X11 #define XSCREENSAVER_MIN_TIMEOUT 60 #endif #ifdef ENABLE_DBUS #define GS_SERVICE "org.gnome.SessionManager" #define GS_PATH "/org/gnome/SessionManager" #define GS_INTERFACE "org.gnome.SessionManager" /* From org.gnome.SessionManager.xml */ #define GS_NO_IDLE_FLAG 8 #define REASON "Playing a movie" static void on_inhibit_cb (GObject * source_object, GAsyncResult * res, gpointer user_data) { GDBusProxy *proxy = G_DBUS_PROXY (source_object); ScreenSaver *screensaver = (ScreenSaver *) user_data; GVariant *value; GError *error = NULL; value = g_dbus_proxy_call_finish (proxy, res, &error); if (!value) { g_warning ("Problem inhibiting the screensaver: %s", error->message); g_error_free (error); return; } /* save the cookie */ if (g_variant_is_of_type (value, G_VARIANT_TYPE ("(u)"))) g_variant_get (value, "(u)", &screensaver->cookie); else screensaver->cookie = 0; g_variant_unref (value); } static void on_uninhibit_cb (GObject * source_object, GAsyncResult * res, gpointer user_data) { GDBusProxy *proxy = G_DBUS_PROXY (source_object); ScreenSaver *screensaver = (ScreenSaver *) user_data; GVariant *value; GError *error = NULL; value = g_dbus_proxy_call_finish (proxy, res, &error); if (!value) { g_warning ("Problem uninhibiting the screensaver: %s", error->message); g_error_free (error); return; } /* clear the cookie */ screensaver->cookie = 0; g_variant_unref (value); } static void screensaver_inhibit_dbus (ScreenSaver * screensaver, gboolean inhibit) { if (!screensaver->gs_proxy) return; if (inhibit) { guint xid; xid = screensaver->window; g_dbus_proxy_call (screensaver->gs_proxy, "Inhibit", g_variant_new ("(susu)", g_get_application_name (), xid, REASON, GS_NO_IDLE_FLAG), G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, on_inhibit_cb, screensaver); } else { if (screensaver->cookie > 0) { g_dbus_proxy_call (screensaver->gs_proxy, "Uninhibit", g_variant_new ("(u)", screensaver->cookie), G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, on_uninhibit_cb, screensaver); } } } static void screensaver_enable_dbus (ScreenSaver * screensaver) { screensaver_inhibit_dbus (screensaver, FALSE); } static void screensaver_disable_dbus (ScreenSaver * screensaver) { screensaver_inhibit_dbus (screensaver, TRUE); } static void screensaver_dbus_proxy_new_cb (GObject * source, GAsyncResult * result, gpointer user_data) { ScreenSaver *screensaver = (ScreenSaver *) user_data; screensaver->gs_proxy = g_dbus_proxy_new_for_bus_finish (result, NULL); if (!screensaver->gs_proxy) return; if (screensaver->disabled) screensaver_disable_dbus (screensaver); } static void screensaver_init_dbus (ScreenSaver * screensaver) { g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, GS_SERVICE, GS_PATH, GS_INTERFACE, NULL, screensaver_dbus_proxy_new_cb, screensaver); } static void screensaver_free_dbus (ScreenSaver * screensaver) { if (screensaver->gs_proxy) g_object_unref (screensaver->gs_proxy); } #endif #ifdef HAVE_X11 static void screensaver_enable_x11 (ScreenSaver * screensaver) { #ifdef HAVE_XTEST if (screensaver->have_xtest) { g_source_remove_by_user_data (screensaver); return; } #endif XLockDisplay (screensaver->display); XSetScreenSaver (screensaver->display, screensaver->timeout, screensaver->interval, screensaver->prefer_blanking, screensaver->allow_exposures); XUnlockDisplay (screensaver->display); } #ifdef HAVE_XTEST static gboolean fake_event (ScreenSaver * screensaver) { if (screensaver->disabled) { XLockDisplay (screensaver->display); XTestFakeKeyEvent (screensaver->display, *screensaver->keycode, True, CurrentTime); XTestFakeKeyEvent (screensaver->display, *screensaver->keycode, False, CurrentTime); XUnlockDisplay (screensaver->display); /* Swap the keycode */ if (screensaver->keycode == &screensaver->keycode1) screensaver->keycode = &screensaver->keycode2; else screensaver->keycode = &screensaver->keycode1; } return TRUE; } #endif static void screensaver_disable_x11 (ScreenSaver * screensaver) { #ifdef HAVE_XTEST if (screensaver->have_xtest) { XLockDisplay (screensaver->display); XGetScreenSaver (screensaver->display, &screensaver->timeout, &screensaver->interval, &screensaver->prefer_blanking, &screensaver->allow_exposures); XUnlockDisplay (screensaver->display); if (screensaver->timeout != 0) { g_timeout_add_seconds (screensaver->timeout / 2, (GSourceFunc) fake_event, screensaver); } else { g_timeout_add_seconds (XSCREENSAVER_MIN_TIMEOUT / 2, (GSourceFunc) fake_event, screensaver); } return; } #endif XLockDisplay (screensaver->display); XGetScreenSaver (screensaver->display, &screensaver->timeout, &screensaver->interval, &screensaver->prefer_blanking, &screensaver->allow_exposures); XSetScreenSaver (screensaver->display, 0, 0, DontPreferBlanking, DontAllowExposures); XUnlockDisplay (screensaver->display); } static void screensaver_init_x11 (ScreenSaver * screensaver) { #ifdef HAVE_XTEST int a, b, c, d; XLockDisplay (screensaver->display); screensaver->have_xtest = (XTestQueryExtension (screensaver->display, &a, &b, &c, &d) == True); if (screensaver->have_xtest) { screensaver->keycode1 = XKeysymToKeycode (screensaver->display, XK_Alt_L); if (screensaver->keycode1 == 0) { g_warning ("keycode1 not existant"); } screensaver->keycode2 = XKeysymToKeycode (screensaver->display, XK_Alt_R); if (screensaver->keycode2 == 0) { screensaver->keycode2 = XKeysymToKeycode (screensaver->display, XK_Alt_L); if (screensaver->keycode2 == 0) { g_warning ("keycode2 not existant"); } } screensaver->keycode = &screensaver->keycode1; } XUnlockDisplay (screensaver->display); #endif } static void screensaver_free_x11 (ScreenSaver * screensaver) { g_source_remove_by_user_data (screensaver); } #endif void screensaver_enable (ScreenSaver * screensaver, gboolean enable) { screensaver->disabled = !enable; #ifdef ENABLE_DBUS if (screensaver->disabled) screensaver_enable_dbus (screensaver); else screensaver_disable_dbus (screensaver); #endif #ifdef HAVE_X11 if (screensaver->disabled) screensaver_enable_x11 (screensaver); else screensaver_disable_x11 (screensaver); #endif } void screensaver_free (ScreenSaver * screensaver) { #ifdef ENABLE_DBUS screensaver_free_dbus (screensaver); #endif #ifdef HAVE_X11 screensaver_free_x11 (screensaver); #endif g_free (screensaver); } ScreenSaver * screensaver_new (ClutterStage * stage) { ScreenSaver *screensaver; screensaver = g_new0 (ScreenSaver, 1); screensaver->disabled = FALSE; screensaver->stage = stage; #if HAVE_X11 screensaver->display = clutter_x11_get_default_display (); screensaver->window = clutter_x11_get_stage_window (stage); screensaver_init_x11 (screensaver); #endif #ifdef ENABLE_DBUS screensaver_init_dbus (screensaver); #endif return screensaver; } snappy-0.3.7/src/screensaver.h000066400000000000000000000022701213407343700163200ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Sebastian Droege * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifndef __SCREENSAVER_H__ #define __SCREENSAVER_H__ #include #include G_BEGIN_DECLS typedef struct _ScreenSaver ScreenSaver; void screensaver_enable (ScreenSaver * screensaver, gboolean enable); void screensaver_free (ScreenSaver * screensaver); ScreenSaver *screensaver_new (ClutterStage * stage); G_END_DECLS #endif /* __SCREENSAVER_H__ */ snappy-0.3.7/src/snappy.c000066400000000000000000000176271213407343700153210ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #define VERSION "0.3.7" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "user_interface.h" #ifdef ENABLE_DBUS #include "dlna.h" #endif #include "gst_engine.h" #include "utils.h" /* Close snappy down */ void close_down (UserInterface * ui, GstEngine * engine) { g_print ("closing snappy\n"); /* Save position if file isn't finished playing */ add_uri_unfinished (engine); /* Close gstreamer gracefully */ change_state (engine, "Null"); /* Re-enable screensaver */ screensaver_enable (ui->screensaver, TRUE); screensaver_free (ui->screensaver); gst_object_unref (G_OBJECT (engine->player)); } /* Process command arguments */ GList * process_args (int argc, char *argv[], gboolean * blind, gboolean * fullscreen, gboolean * hide, gboolean * loop, gboolean * secret, gchar ** suburi, gboolean * tags, GOptionContext * context) { gboolean recent = FALSE, version = FALSE; guint c, index, pos = 0; GList *uri_list = NULL; GOptionEntry entries[] = { {"blind", 'b', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, blind, "Blind mode", NULL}, {"fullscreen", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, fullscreen, "Fullscreen mode", NULL}, {"hide-controls", 'h', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, hide, "Hide on screen controls", NULL}, {"loop", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, loop, "Looping mode", NULL}, {"media-info", 'i', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, tags, "Print media information", NULL}, {"recent", 'r', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &recent, "Show recently viewed", NULL}, {"secret", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, secret, "Views not saved in recently viewed history", NULL}, {"subtitles", 't', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_FILENAME, suburi, "Use this subtitle file", NULL}, {"version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, "Shows snappy's version", NULL}, {NULL} }; GError *err = NULL; g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gst_init_get_option_group ()); g_option_context_add_group (context, clutter_get_option_group ()); /* Check command arguments and update entry variables */ if (!g_option_context_parse (context, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", err->message); g_error_free (err); return NULL; } /* Recently viewed uris */ if (recent) { gchar **recent = NULL; recent = get_recently_viewed (); if (recent) { g_print ("These are the recently viewed URIs: \n\n"); for (c = 0; recent[c] != NULL; c++) { if (c < 9) g_print ("0%d: %s \n", c + 1, recent[c]); else g_print ("%d: %s \n", c + 1, recent[c]); } } else { g_print ("ERROR: Can't find history of recently viewed URIs\n"); } return NULL; } /* Show snappy's version */ if (version) { g_print ("snappy version %s\n", VERSION); return NULL; } /* Check that at least one URI has been introduced */ if (argc > 1) { /* Save uris in the file glist */ for (index = 1; index < argc; index++) { g_print ("Adding file: %s\n", argv[index]); uri_list = g_list_append (uri_list, clean_uri (argv[index])); pos++; } } else { /* If no files passed by user display help */ g_print ("Opening snappy without content.\n\n"); g_print ("%s", g_option_context_get_help (context, TRUE, NULL)); } return uri_list; } /* snappy's main function */ int main (int argc, char *argv[]) { UserInterface *ui = NULL; GstEngine *engine = NULL; ClutterActor *video_texture; GstElement *sink; gboolean ok, blind = FALSE, fullscreen = FALSE, hide = FALSE, loop = FALSE; gboolean secret = FALSE, tags = FALSE; gint ret = 0; guint c, index, pos = 0; gchar *uri = NULL; gchar *suburi = NULL; gchar *version_str; GList *uri_list; GOptionContext *context; gchar *data_dir; #ifdef ENABLE_DBUS SnappyMP *mp_obj = NULL; #endif gtk_clutter_init (&argc, &argv); /* Try to find the path for our resources in case snappy was relocated */ data_dir = g_strdup (SNAPPY_DATA_DIR); if (!g_file_test (data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { gchar *root_dir; #ifdef G_OS_WIN32 root_dir = g_win32_get_package_installation_directory_of_module (NULL); #elif !defined(G_OS_UNIX) gchar *exec_path; gchar *bin_dir; exec_path = g_file_read_link ("/proc/self/exe", NULL); bin_dir = g_path_get_dirname (exec_path); root_dir = g_build_filename (bin_dir, "..", NULL); g_free (exec_path); g_free (bin_dir); #else root_dir = NULL; #endif if (root_dir != NULL) { data_dir = g_build_filename (root_dir, "share", "snappy", NULL); g_free (root_dir); } } context = g_option_context_new (" - Play movie files"); /* Process command arguments */ uri_list = process_args (argc, argv, &blind, &fullscreen, &hide, &loop, &secret, &suburi, &tags, context); /* User Interface */ ui = g_new (UserInterface, 1); ui->uri_list = uri_list; ui->blind = blind; ui->fullscreen = fullscreen; ui->hide = hide; ui->tags = tags; ui->data_dir = data_dir; interface_init (ui); video_texture = g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL); version_str = gst_version_string (); GST_DEBUG_CATEGORY_INIT (_snappy_gst_debug, "snappy", 0, "snappy media player"); GST_DEBUG ("Initialised %s", version_str); /* Gstreamer engine */ engine = g_new (GstEngine, 1); sink = gst_element_factory_make ("autocluttersink", "cluttersink"); if (sink == NULL) { GST_DEBUG ("autocluttersink not found, falling back to cluttersink\n"); sink = gst_element_factory_make ("cluttersink", "cluttersink"); } g_object_set (G_OBJECT (sink), "texture", video_texture, NULL); ok = engine_init (engine, sink); if (!ok) goto quit; engine->secret = secret; engine->loop = loop; ui->engine = engine; ui->texture = video_texture; gst_bus_add_watch (engine->bus, bus_call, ui); gst_object_unref (engine->bus); /* Get uri to load */ if (uri_list) uri = g_list_first (uri_list)->data; /* Load engine and start interface */ engine_load_uri (engine, uri); interface_start (ui, uri); /* Load subtitle file if available */ if (suburi != NULL) { suburi = clean_uri (suburi); set_subtitle_uri (engine, suburi); } /* Start playing if we have a URI to play */ if (uri) { change_state (engine, "Paused"); change_state (engine, "Playing"); } #ifdef ENABLE_DBUS /* Start MPRIS Dbus object */ mp_obj = g_new (SnappyMP, 1); mp_obj->engine = engine; mp_obj->ui = ui; load_dlna (mp_obj); #endif /* Main loop */ gtk_main (); /* Close snappy */ close_down (ui, engine); #ifdef ENABLE_DBUS close_dlna (mp_obj); #endif quit: g_list_free (uri_list); g_option_context_free (context); return ret; } snappy-0.3.7/src/user_interface.c000066400000000000000000001433261213407343700170010ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-213 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #include #include #include #include #include #include #include #include "user_interface.h" #include "utils.h" // Declaration of static functions static gboolean controls_timeout_cb (gpointer data); static gboolean draw_background (ClutterCanvas * canvas, cairo_t * cr, int surface_width, int surface_height, UserInterface * ui); static gboolean draw_progressbar (ClutterCanvas * canvas, cairo_t * cr, int surface_width, int surface_height, UserInterface * ui); static gboolean event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui); static void hide_cursor (UserInterface * ui); static void load_controls (UserInterface * ui); static void new_video_size (UserInterface * ui, gfloat width, gfloat height, gfloat * new_width, gfloat * new_height); static gboolean penalty_box (gpointer data); static gchar *position_ns_to_str (gint64 nanoseconds); static void progress_timing (UserInterface * ui); static gboolean progress_update_text (gpointer data); static gboolean progress_update_seekbar (gpointer data); gboolean rotate_video (UserInterface * ui); static void size_change (ClutterStage * stage, const ClutterActorBox * allocation, ClutterAllocationFlags flags, UserInterface * ui); static void show_controls (UserInterface * ui, gboolean vis); static void toggle_fullscreen (UserInterface * ui); static void toggle_playing (UserInterface * ui); static void update_controls_size (UserInterface * ui); static gboolean update_volume (UserInterface * ui, gdouble volume); /* ---------------------- static functions ----------------------- */ static gboolean controls_timeout_cb (gpointer data) { UserInterface *ui = data; ui->controls_timeout = -1; hide_cursor (ui); if (!ui->keep_showing_controls) { show_controls (ui, FALSE); } return FALSE; } static gboolean draw_background (ClutterCanvas * canvas, cairo_t * cr, int surface_width, int surface_height, UserInterface * ui) { /* rounded rectangle taken from: * * http://cairographics.org/samples/rounded_rectangle/ * */ double x, y, width, height, aspect, corner_radius, radius, degrees; double red, green, blue, alpha; x = 1.0; y = 1.0; width = surface_width - 2.0; height = surface_height - 2.0; aspect = 1.0; // aspect ratio corner_radius = height / 15.0; // and corner curvature radius radius = corner_radius / aspect; degrees = M_PI / 180.0; cairo_save (cr); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_restore (cr); cairo_new_sub_path (cr); cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees); cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees); cairo_arc (cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees); cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees); cairo_close_path (cr); red = (double) ui->stage_bg_color.red / 256.0; green = (double) ui->stage_bg_color.green / 256.0; blue = (double) ui->stage_bg_color.blue / 256.0; alpha = (double) ui->stage_bg_color.alpha / 256.0; cairo_set_source_rgba (cr, red, green, blue, alpha); cairo_close_path (cr); cairo_fill_preserve (cr); red = (double) ui->border_color.red / 256.0; green = (double) ui->border_color.green / 256.0; blue = (double) ui->border_color.blue / 256.0; alpha = (double) ui->border_color.alpha / 256.0; cairo_set_source_rgba (cr, red, green, blue, alpha); cairo_stroke (cr); // We are done drawing return TRUE; } static gboolean draw_progressbar (ClutterCanvas * canvas, cairo_t * cr, int surface_width, int surface_height, UserInterface * ui) { double x, y, width, height, aspect, corner_radius, radius, degrees; double red, green, blue, alpha; gfloat position; cairo_pattern_t *pattern; x = 1.0; y = 1.0; width = surface_width - 2.0; height = surface_height - 2.0; aspect = 1.0; // aspect ratio corner_radius = height / 4.0; // and corner curvature radius radius = corner_radius / aspect; degrees = M_PI / 180.0; cairo_save (cr); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_restore (cr); pattern = cairo_pattern_create_linear (0.0, 0.0, surface_width, 0.0); if (canvas == CLUTTER_CANVAS (ui->seek_canvas)) { // if called for seek canvas, update playback position position = ui->playback_position; } else { // if called for volume canvas, update volume level position = ui->volume; } red = (double) ui->gradient_start.red / 256.0; green = (double) ui->gradient_start.green / 256.0; blue = (double) ui->gradient_start.blue / 256.0; alpha = (double) ui->gradient_start.alpha / 256.0; cairo_pattern_add_color_stop_rgba (pattern, 0.0, red, green, blue, alpha); red = (double) ui->gradient_finish.red / 256.0; green = (double) ui->gradient_finish.green / 256.0; blue = (double) ui->gradient_finish.blue / 256.0; alpha = (double) ui->gradient_finish.alpha / 256.0; cairo_pattern_add_color_stop_rgba (pattern, position, red, green, blue, alpha); cairo_pattern_add_color_stop_rgba (pattern, position + 0.0001, 0, 0, 0, 0.0); cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0.0); cairo_set_source (cr, pattern); cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees); cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees); cairo_arc (cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees); cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees); cairo_close_path (cr); cairo_fill_preserve (cr); red = (double) ui->border_color.red / 256.0; green = (double) ui->border_color.green / 256.0; blue = (double) ui->border_color.blue / 256.0; alpha = (double) ui->border_color.alpha / 256.0; cairo_set_source_rgba (cr, red, green, blue, alpha); cairo_stroke (cr); // We are done drawing return TRUE; } static gboolean event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui) { gboolean handled = FALSE; switch (event->type) { case CLUTTER_KEY_PRESS: { /* Clutter key codes based on */ /* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h */ guint keyval = clutter_event_get_key_symbol (event); switch (keyval) { case CLUTTER_q: case CLUTTER_Q: case CLUTTER_Escape: { gtk_main_quit (); handled = TRUE; break; } case CLUTTER_f: case CLUTTER_F: case CLUTTER_F11: { // Fullscreen keys toggle_fullscreen (ui); handled = TRUE; break; } case CLUTTER_space: { // Spacebar toggle_playing (ui); handled = TRUE; break; } case CLUTTER_l: case CLUTTER_L: { // Loop ui->engine->loop = !ui->engine->loop; handled = TRUE; break; } case CLUTTER_8: { // Mute button gdouble volume; gboolean muteval; g_object_get (G_OBJECT (ui->engine->player), "mute", &muteval, NULL); g_object_set (G_OBJECT (ui->engine->player), "mute", !muteval, NULL); update_volume (ui, volume); handled = TRUE; break; } case CLUTTER_9: case CLUTTER_0: { gdouble volume; g_object_get (G_OBJECT (ui->engine->player), "volume", &volume, NULL); // Volume Down if (keyval == CLUTTER_9 && volume > 0.0) { volume -= 0.05; if (volume < 0.01) volume = 0; g_object_set (G_OBJECT (ui->engine->player), "volume", volume, NULL); // Volume Up } else if (keyval == CLUTTER_0 && volume < 1.0) { volume += 0.05; if (volume > 1) volume = 1; g_object_set (G_OBJECT (ui->engine->player), "volume", volume, NULL); } update_volume (ui, volume); handled = TRUE; break; } case CLUTTER_Up: case CLUTTER_Down: case CLUTTER_Left: case CLUTTER_Right: case CLUTTER_Page_Up: case CLUTTER_Page_Down: { gint64 pos, second; gfloat progress; pos = query_position (ui->engine); second = ui->engine->second; if (keyval == CLUTTER_Up) { // Seek 1 minute foward pos += 60 * second; } else if (keyval == CLUTTER_Down) { // Seek 1 minute back pos -= 60 * second; } else if (keyval == CLUTTER_Right) { // Seek 10 seconds foward pos += 10 * second; } else if (keyval == CLUTTER_Left) { // Seek 10 seconds back pos -= 10 * second; } else if (keyval == CLUTTER_Page_Up) { // Seek 10 minutes foward pos += 600 * second; } else if (keyval == CLUTTER_Page_Down) { // Seek 10 minutes back pos -= 600 * second; } /* clamp the timestamp to be within the media */ pos = CLAMP (pos, 0, ui->engine->media_duration); engine_seek (ui->engine, pos, FALSE); ui->playback_position = (float) pos / ui->engine->media_duration; // Invalidate calls a redraw of the canvas clutter_content_invalidate (ui->seek_canvas); handled = TRUE; break; } case CLUTTER_r: case CLUTTER_R: { // rotate texture 90 degrees. rotate_video (ui); handled = TRUE; break; } case CLUTTER_c: case CLUTTER_C: { // show or hide controls penalty_box (ui); ui->keep_showing_controls = !ui->controls_showing; show_controls (ui, !ui->controls_showing); handled = TRUE; break; } case CLUTTER_period: { // frame step forward frame_stepping (ui->engine, TRUE); handled = TRUE; break; } case CLUTTER_comma: { // frame step backward frame_stepping (ui->engine, FALSE); handled = TRUE; break; } case CLUTTER_v: case CLUTTER_V: { // toggle subtitles if (toggle_subtitles (ui->engine)) { gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->subtitle_toggle), gdk_pixbuf_new_from_file (ui->subtitle_active_png, NULL), NULL); } else { gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->subtitle_toggle), gdk_pixbuf_new_from_file (ui->subtitle_inactive_png, NULL), NULL); } handled = TRUE; break; } case CLUTTER_numbersign: case CLUTTER_underscore: case CLUTTER_j: case CLUTTER_J: { // cycle through available audio/text/video streams guint streamid; if (keyval == CLUTTER_numbersign) streamid = STREAM_AUDIO; else if (keyval == CLUTTER_j || keyval == CLUTTER_J) streamid = STREAM_TEXT; else if (keyval == CLUTTER_underscore) streamid = STREAM_VIDEO; cycle_streams (ui->engine, streamid); handled = TRUE; break; } case CLUTTER_less: { interface_play_next_or_prev (ui, FALSE); break; } case CLUTTER_greater: { interface_play_next_or_prev (ui, TRUE); break; } default: { handled = FALSE; break; } } break; } case CLUTTER_BUTTON_PRESS: { if (ui->controls_showing) { ClutterActor *actor; ClutterButtonEvent *bev = (ClutterButtonEvent *) event; actor = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, bev->x, bev->y); if (actor == ui->control_play_toggle) { toggle_playing (ui); } else if (actor == ui->control_seekbar) { gfloat x, y, dist; gint64 pos; clutter_actor_get_transformed_position (ui->control_seekbar, &x, &y); dist = bev->x - x; dist = CLAMP (dist, 0, ui->seek_width); if (ui->engine->media_duration == -1) { update_media_duration (ui->engine); } pos = ui->engine->media_duration * (dist / ui->seek_width); engine_seek (ui->engine, pos, FALSE); ui->playback_position = (float) pos / ui->engine->media_duration; // Invalidate calls a redraw of the canvas clutter_content_invalidate (ui->seek_canvas); } else if (actor == ui->vol_int) { gfloat x, y, dist; gdouble volume; clutter_actor_get_transformed_position (ui->vol_int, &x, &y); dist = bev->x - x; dist = CLAMP (dist, 0, ui->volume_width); volume = dist / ui->volume_width; g_object_set (G_OBJECT (ui->engine->player), "volume", volume, NULL); ui->volume = (float) volume; clutter_content_invalidate (ui->vol_int_canvas); } else if (actor == ui->texture || actor == ui->stage) { if (!ui->penalty_box_active) { penalty_box (ui); show_controls (ui, FALSE); } } else if (actor == ui->fullscreen_button) { // Fullscreen button toggle_fullscreen (ui); } else if (actor == ui->audio_stream_toggle) { cycle_streams (ui->engine, STREAM_AUDIO); } else if (actor == ui->subtitle_toggle) { if (toggle_subtitles (ui->engine)) { gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->subtitle_toggle), gdk_pixbuf_new_from_file (ui->subtitle_active_png, NULL), NULL); } else { gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->subtitle_toggle), gdk_pixbuf_new_from_file (ui->subtitle_inactive_png, NULL), NULL); } } else if (actor == ui->video_stream_toggle) { cycle_streams (ui->engine, STREAM_VIDEO); } } handled = TRUE; break; } case CLUTTER_MOTION: { if (!ui->penalty_box_active) show_controls (ui, TRUE); handled = TRUE; break; } } return handled; } static void hide_cursor (UserInterface * ui) { ClutterDeviceManager *manager = NULL; ClutterInputDevice *device = NULL; ClutterPoint point; manager = clutter_device_manager_get_default (); device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE); clutter_input_device_get_coords (device, NULL, &point); if (point.x > 0 && point.y > 0 && point.x < ui->stage_width && point.y < ui->stage_height) { clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage)); } } static void load_controls (UserInterface * ui) { // Check icon files exist gchar *icon_files[9]; gchar *duration_str = NULL; gint c; gfloat pos; ClutterContent *canvas; ClutterLayoutManager *controls_layout = NULL; ClutterLayoutManager *bottom_box_layout = NULL; ClutterLayoutManager *volume_box_layout = NULL; ClutterLayoutManager *right_box_layout = NULL; ClutterActor *middle_box = NULL; ClutterActor *bottom_box = NULL; ClutterActor *vol_int_box = NULL; ClutterActor *right_box = NULL; GError *error = NULL; ui->play_png = g_build_filename (ui->data_dir, "media-actions-start.svg", NULL); ui->pause_png = g_build_filename (ui->data_dir, "media-actions-pause.svg", NULL); ui->volume_low_png = g_build_filename (ui->data_dir, "audio-volume-low.svg", NULL); ui->volume_high_png = g_build_filename (ui->data_dir, "audio-volume-high.svg", NULL); ui->fullscreen_svg = g_build_filename (ui->data_dir, "fullscreen.svg", NULL); ui->subtitle_active_png = g_build_filename (ui->data_dir, "subtitles-active.svg", NULL); ui->subtitle_inactive_png = g_build_filename (ui->data_dir, "subtitles-inactive.svg", NULL); ui->video_stream_toggle_png = g_build_filename (ui->data_dir, "video-stream-toggle.png", NULL); ui->audio_stream_toggle_png = g_build_filename (ui->data_dir, "audio-stream-toggle.png", NULL); icon_files[0] = ui->play_png; icon_files[1] = ui->pause_png; icon_files[2] = ui->volume_low_png; icon_files[3] = ui->volume_high_png; icon_files[4] = ui->fullscreen_svg; icon_files[5] = ui->subtitle_active_png; icon_files[6] = ui->subtitle_inactive_png; icon_files[7] = ui->video_stream_toggle_png; icon_files[8] = ui->audio_stream_toggle_png; for (c = 0; c < 9; c++) { if (!g_file_test (icon_files[c], G_FILE_TEST_EXISTS)) { g_print ("Icon file doesn't exist, are you sure you have " " installed snappy correctly?\nThis file needed is: %s\n", icon_files[c]); } } // Controls layout management controls_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); ui->control_box = clutter_actor_new (); clutter_actor_set_layout_manager (ui->control_box, controls_layout); // Controls rectangular background with curved edges (drawn in cairo) canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), ui->media_width * CONTROLS_WIDTH_RATIO, ui->media_height * CONTROLS_HEIGHT_RATIO); ui->control_bg = clutter_actor_new (); clutter_actor_set_content (ui->control_bg, canvas); // The actor now owns the canvas g_object_unref (canvas); g_signal_connect (canvas, "draw", G_CALLBACK (draw_background), ui); // Invalidate the canvas, so that we can draw before the main loop starts clutter_content_invalidate (canvas); clutter_actor_add_constraint (ui->control_bg, clutter_bind_constraint_new (ui->control_box, CLUTTER_BIND_SIZE, 0)); clutter_actor_add_child (CLUTTER_ACTOR (ui->control_box), ui->control_bg); clutter_actor_add_constraint (ui->control_box, clutter_align_constraint_new (ui->stage, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (ui->control_box, clutter_align_constraint_new (ui->stage, CLUTTER_ALIGN_Y_AXIS, 0.95)); // Main Box ui->main_box_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (ui->main_box_layout), CLUTTER_ORIENTATION_VERTICAL); ui->main_box = clutter_actor_new (); clutter_actor_set_layout_manager (ui->main_box, ui->main_box_layout); clutter_actor_add_child (CLUTTER_ACTOR (ui->control_box), CLUTTER_ACTOR (ui->main_box)); // Controls title ui->control_title = clutter_text_new_full ("Clear Sans Bold 32px", cut_long_filename (ui->filename, ui->title_length), &ui->text_color); if (strcmp (ui->filename, "") == 0) { clutter_text_set_text (CLUTTER_TEXT (ui->control_title), "Drag and drop a file here to play it"); } clutter_text_set_max_length (CLUTTER_TEXT (ui->control_title), ui->title_length); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->main_box_layout), ui->control_title, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Info Box ui->info_box_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (ui->info_box_layout), CLUTTER_ORIENTATION_HORIZONTAL); ui->info_box = clutter_actor_new (); clutter_actor_set_layout_manager (ui->info_box, ui->info_box_layout); // Controls play toggle ui->control_play_toggle = gtk_clutter_texture_new (); if (strcmp (ui->filename, "") == 0) { gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->control_play_toggle), gdk_pixbuf_new_from_file (ui->play_png, NULL), &error); } else { gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->control_play_toggle), gdk_pixbuf_new_from_file (ui->pause_png, NULL), &error); } if (!ui->control_play_toggle && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } g_assert (ui->control_bg && ui->control_play_toggle); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->info_box_layout), ui->control_play_toggle, FALSE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Position, volume and streams box ui->pos_n_vol_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (ui->pos_n_vol_layout), CLUTTER_ORIENTATION_VERTICAL); ui->pos_n_vol_box = clutter_actor_new (); clutter_actor_set_layout_manager (ui->pos_n_vol_box, ui->pos_n_vol_layout); // Seek progress bar ui->seek_canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (ui->seek_canvas), ui->media_width * CONTROLS_WIDTH_RATIO, (ui->media_height * CONTROLS_HEIGHT_RATIO) / 5); ui->control_seekbar = clutter_actor_new (); clutter_actor_set_content (ui->control_seekbar, ui->seek_canvas); g_signal_connect (ui->seek_canvas, "draw", G_CALLBACK (draw_progressbar), ui); clutter_content_invalidate (ui->seek_canvas); // Add seek box to Position and Volume Layout clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->pos_n_vol_layout), ui->control_seekbar, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_END, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Controls middle box ui->middle_box_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (ui->middle_box_layout), CLUTTER_ORIENTATION_HORIZONTAL); middle_box = clutter_actor_new (); clutter_actor_set_layout_manager (middle_box, ui->middle_box_layout); // Controls volume box volume_box_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (volume_box_layout), CLUTTER_ORIENTATION_HORIZONTAL); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (volume_box_layout), 5); ui->volume_box = clutter_actor_new (); clutter_actor_set_layout_manager (ui->volume_box, volume_box_layout); clutter_actor_add_child (middle_box, ui->volume_box); // Controls volume low ui->volume_low = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->volume_low), gdk_pixbuf_new_from_file (ui->volume_low_png, NULL), &error); if (!ui->volume_low && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } clutter_actor_add_child (ui->volume_box, ui->volume_low); // Controls volume intensity vol_int_box = clutter_actor_new (); ui->vol_int_canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (ui->vol_int_canvas), ui->media_width * CONTROLS_WIDTH_RATIO, (ui->media_height * CONTROLS_HEIGHT_RATIO) / 5); ui->vol_int = clutter_actor_new (); clutter_actor_set_content (ui->vol_int, ui->vol_int_canvas); g_signal_connect (ui->vol_int_canvas, "draw", G_CALLBACK (draw_progressbar), ui); clutter_content_invalidate (ui->vol_int_canvas); clutter_actor_add_child (vol_int_box, ui->vol_int); clutter_actor_add_child (ui->volume_box, vol_int_box); // Controls volume high ui->volume_high = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->volume_high), gdk_pixbuf_new_from_file (ui->volume_high_png, NULL), &error); if (!ui->volume_high && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } clutter_actor_add_child (ui->volume_box, ui->volume_high); // Controls position text duration_str = g_strdup_printf (" 0:00:00 | %s", ui->duration_str); ui->control_pos = clutter_text_new_full ("Clear Sans 22px", duration_str, &ui->text_color); clutter_actor_add_child (middle_box, ui->control_pos); // Add middle box (volume and text position) to Position and Volume Layout clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->pos_n_vol_layout), middle_box, TRUE, /* expand */ TRUE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ if (FALSE) { // hide this buttons (TODO: optional Flag) // Controls bottom box bottom_box_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (bottom_box_layout), CLUTTER_ORIENTATION_HORIZONTAL); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (bottom_box_layout), 5); bottom_box = clutter_actor_new (); clutter_actor_set_layout_manager (bottom_box, bottom_box_layout); // Controls video stream toggle ui->video_stream_toggle = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->video_stream_toggle), gdk_pixbuf_new_from_file (ui->video_stream_toggle_png, NULL), &error); if (!ui->video_stream_toggle && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } clutter_actor_add_child (bottom_box, ui->video_stream_toggle); // Controls audio stream toggle ui->audio_stream_toggle = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->audio_stream_toggle), gdk_pixbuf_new_from_file (ui->audio_stream_toggle_png, NULL), &error); if (!ui->audio_stream_toggle && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } clutter_actor_add_child (bottom_box, ui->audio_stream_toggle); // Add bottom box (different streams) to Position and Volume Layout clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->pos_n_vol_layout), bottom_box, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_END, /* x-align */ CLUTTER_BOX_ALIGNMENT_END); /* y-align */ } clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->info_box_layout), ui->pos_n_vol_box, FALSE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Controls right box for subtitles and fullscreen right_box_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (right_box_layout), CLUTTER_ORIENTATION_HORIZONTAL); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (right_box_layout), 10); right_box = clutter_actor_new (); clutter_actor_set_layout_manager (right_box, right_box_layout); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->info_box_layout), right_box, FALSE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Controls subtitle toggle ui->subtitle_toggle = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->subtitle_toggle), gdk_pixbuf_new_from_file (ui->subtitle_active_png, NULL), &error); if (!ui->subtitle_toggle && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } clutter_actor_hide (ui->subtitle_toggle); clutter_actor_add_child (right_box, ui->subtitle_toggle); // Controls fullscreen ui->fullscreen_button = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->fullscreen_button), gdk_pixbuf_new_from_file (ui->fullscreen_svg, NULL), &error); if (!ui->fullscreen_button && error) g_debug ("Clutter error: %s", error->message); if (error) { g_error_free (error); error = NULL; } clutter_actor_add_child (right_box, ui->fullscreen_button); // Add Info Box to Main Box Layout clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->main_box_layout), ui->info_box, FALSE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ clutter_actor_set_child_below_sibling (ui->control_box, ui->control_bg, ui->main_box); size_change (CLUTTER_STAGE (ui->stage), NULL, 0, ui); } static void new_video_size (UserInterface * ui, gfloat width, gfloat height, gfloat * new_width, gfloat * new_height) { gfloat tmp_width, tmp_height; gfloat media_width, media_height; gfloat stage_ar, media_ar; media_width = clutter_actor_get_width (ui->texture); media_height = clutter_actor_get_height (ui->texture); stage_ar = width / height; tmp_width = width; tmp_height = height; if (media_height > 0.0f && media_width > 0.0f) { media_ar = media_width / media_height; /* calculate new width and height * note: when we're done, new_width/new_height should equal media_ar */ if (media_ar > stage_ar) { /* media has wider aspect than stage so use new width as stage width and * scale down height */ tmp_height = width / media_ar; } else { tmp_width = height * media_ar; } } else { g_debug ("Warning: not considering texture dimensions %fx%f", media_width, media_height); } *new_width = tmp_width; *new_height = tmp_height; } static gboolean penalty_box (gpointer data) { UserInterface *ui = (UserInterface *) data; if (ui->penalty_box_active) { ui->penalty_box_active = FALSE; } else { ui->penalty_box_active = TRUE; g_timeout_add (PENALTY_TIME, penalty_box, ui); } return FALSE; } static gchar * position_ns_to_str (gint64 nanoseconds) { gint64 seconds; gint hours, minutes; seconds = nanoseconds / GST_SECOND; hours = seconds / SEC_IN_HOUR; seconds = seconds - (hours * SEC_IN_HOUR); minutes = seconds / SEC_IN_MIN; seconds = seconds - (minutes * SEC_IN_MIN); if (hours >= 1) return g_strdup_printf ("%d:%02d:%02ld", hours, minutes, seconds); else return g_strdup_printf ("%02d:%02ld", minutes, seconds); } static void progress_timing (UserInterface * ui) { gint64 duration_ms; gint64 timeout_ms; if (ui->progress_id != -1) g_source_remove (ui->progress_id); duration_ms = ui->engine->media_duration / GST_MSECOND; if (duration_ms > 0) { timeout_ms = MAX (250, duration_ms / ui->seek_width); ui->progress_id = g_timeout_add (timeout_ms, progress_update_seekbar, ui); } } static gboolean progress_update_text (gpointer data) { UserInterface *ui = (UserInterface *) data; GstEngine *engine = ui->engine; if (ui->controls_showing && !engine->queries_blocked) { if (engine->media_duration != -1) { gchar *duration_str; gint64 pos; if (ui->media_duration != engine->media_duration) { ui->duration_str = position_ns_to_str (engine->media_duration); progress_timing (ui); } pos = query_position (engine); duration_str = g_strdup_printf (" %s | %s", position_ns_to_str (pos), ui->duration_str); clutter_text_set_text (CLUTTER_TEXT (ui->control_pos), duration_str); } } return TRUE; } static gboolean progress_update_seekbar (gpointer data) { UserInterface *ui = (UserInterface *) data; GstEngine *engine = ui->engine; if (ui->controls_showing && !engine->queries_blocked) { if (engine->media_duration != -1) { gfloat pos; pos = (float) query_position (engine) / engine->media_duration; ui->playback_position = pos; // Invalidate calls a redraw of the canvas clutter_content_invalidate (ui->seek_canvas); } } return TRUE; } gboolean rotate_video (UserInterface * ui) { gfloat vid_width, vid_height; gfloat x_center, y_center; gdouble angle; angle = clutter_actor_get_rotation_angle (ui->texture, CLUTTER_Z_AXIS); angle += 90; if (angle == 360) angle = 0; clutter_actor_set_rotation_angle (ui->texture, CLUTTER_Z_AXIS, angle); size_change (CLUTTER_STAGE (ui->stage), NULL, 0, ui); return TRUE; } static void size_change (ClutterStage * stage, const ClutterActorBox * allocation, ClutterAllocationFlags flags, UserInterface * ui) { gfloat stage_width, stage_height; gfloat video_width, video_height; ui->stage_width = clutter_actor_get_width (ui->stage); ui->stage_height = clutter_actor_get_height (ui->stage); new_video_size (ui, ui->stage_width, ui->stage_height, &video_width, &video_height); clutter_actor_set_size (CLUTTER_ACTOR (ui->texture), video_width, video_height); update_controls_size (ui); progress_timing (ui); } static void show_controls (UserInterface * ui, gboolean vis) { gboolean cursor; if (vis == TRUE && ui->controls_showing == TRUE) { // ToDo: add 3 more seconds to the controls hiding delay g_object_get (G_OBJECT (ui->stage), "cursor-visible", &cursor, NULL); if (!cursor) clutter_stage_show_cursor (CLUTTER_STAGE (ui->stage)); if (ui->controls_timeout == -1) { ui->controls_timeout = g_timeout_add_seconds (CTL_SHOW_SEC, controls_timeout_cb, ui); } } else if (vis == TRUE && ui->controls_showing == FALSE) { ui->controls_showing = TRUE; if (ui->subtitles_available) { clutter_actor_show (ui->subtitle_toggle); } else { clutter_actor_hide (ui->subtitle_toggle); } update_controls_size (ui); progress_update_seekbar (ui); progress_update_text (ui); clutter_stage_show_cursor (CLUTTER_STAGE (ui->stage)); clutter_actor_animate (CLUTTER_ACTOR (ui->control_box), CLUTTER_EASE_OUT_QUINT, CTL_FADE_DURATION, "opacity", 0xff, NULL); if (ui->controls_timeout == -1) { ui->controls_timeout = g_timeout_add_seconds (CTL_SHOW_SEC, controls_timeout_cb, ui); } } else if (vis == FALSE && ui->controls_showing == TRUE) { ui->controls_showing = FALSE; hide_cursor (ui); clutter_actor_animate (CLUTTER_ACTOR (ui->control_box), CLUTTER_EASE_OUT_QUINT, CTL_FADE_DURATION, "opacity", 0, NULL); } } static void toggle_fullscreen (UserInterface * ui) { gfloat new_width, new_height; if (!ui->fullscreen) { ui->windowed_width = clutter_actor_get_width (ui->stage); ui->windowed_height = clutter_actor_get_height (ui->stage); new_video_size (ui, ui->screen_width, ui->screen_height, &new_width, &new_height); clutter_actor_set_size (CLUTTER_ACTOR (ui->texture), new_width, new_height); gtk_window_fullscreen (GTK_WINDOW (ui->window)); ui->fullscreen = TRUE; } else { gtk_window_unfullscreen (GTK_WINDOW (ui->window)); new_video_size (ui, ui->windowed_width, ui->windowed_height, &new_width, &new_height); clutter_actor_set_size (CLUTTER_ACTOR (ui->texture), new_width, new_height); ui->fullscreen = FALSE; } } static void toggle_playing (UserInterface * ui) { GstEngine *engine = ui->engine; if (engine->playing) { change_state (engine, "Paused"); engine->playing = FALSE; gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->control_play_toggle), gdk_pixbuf_new_from_file (ui->play_png, NULL), NULL); } else { change_state (engine, "Playing"); engine->playing = TRUE; gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->control_play_toggle), gdk_pixbuf_new_from_file (ui->pause_png, NULL), NULL); } } static void update_controls_size (UserInterface * ui) { gchar *font_name; gfloat ctl_width, ctl_height; gfloat icon_size; gfloat control_box_width, control_box_height; gfloat main_box_width, main_box_height; gfloat main_box_horiz_pos, main_box_vert_pos; // g_print ("Updating controls size for stage: %ux%u\n", ui->stage_width, // ui->stage_height); ctl_width = ui->stage_width * CONTROLS_WIDTH_RATIO; ctl_height = ui->stage_height * CONTROLS_HEIGHT_RATIO; if (ctl_width / ctl_height > CONTROLS_ASPECT_RATIO) { ctl_width = ctl_height * CONTROLS_ASPECT_RATIO; } else { ctl_height = ctl_width / CONTROLS_ASPECT_RATIO; } if (ctl_width > CONTROLS_MAX_WIDTH) { ctl_width = CONTROLS_MAX_WIDTH; ctl_height = ctl_width / CONTROLS_ASPECT_RATIO; } else if (ctl_width < CONTROLS_MIN_WIDTH) { ctl_width = CONTROLS_MIN_WIDTH; ctl_height = ctl_width / CONTROLS_ASPECT_RATIO; } icon_size = ctl_height * PLAY_TOGGLE_RATIO; if (ui->subtitles_available) { control_box_width = ctl_width + (icon_size * 2.0f); } else { control_box_width = ctl_width + (icon_size); } control_box_height = ctl_height * 0.85; clutter_actor_set_size (CLUTTER_ACTOR (ui->control_box), control_box_width, control_box_height); clutter_actor_set_size (ui->control_play_toggle, icon_size, icon_size); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (ui->info_box_layout), ctl_width * 0.04f); font_name = g_strdup_printf ("Clear Sans Bold %dpx", (gint) (ctl_width * TITLE_RATIO)); clutter_text_set_font_name (CLUTTER_TEXT (ui->control_title), font_name); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (ui->main_box_layout), ctl_height * 0.10f); ui->seek_width = 12 + // accomodate volume_box spacing (ctl_width * MAIN_BOX_W - icon_size) * SEEK_WIDTH_RATIO - 4.0f; ui->seek_height = ctl_height * MAIN_BOX_H * SEEK_HEIGHT_RATIO - 4.0f; clutter_actor_set_size (ui->control_seekbar, ui->seek_width + 4.0f, ui->seek_height + 4.0f); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (ui->pos_n_vol_layout), ctl_height * 0.16f); progress_update_seekbar (ui); font_name = g_strdup_printf ("Clear Sans %dpx", (gint) (ctl_height * POS_RATIO)); clutter_text_set_font_name (CLUTTER_TEXT (ui->control_pos), font_name); ui->volume_width = (ctl_width * MAIN_BOX_W - icon_size - clutter_actor_get_width (CLUTTER_ACTOR (ui->control_pos))) * VOLUME_WIDTH_RATIO; ui->volume_height = ctl_height * MAIN_BOX_H * VOLUME_HEIGHT_RATIO; clutter_actor_set_size (ui->vol_int, ui->volume_width, ui->volume_height); icon_size = ctl_height * VOLUME_ICON_RATIO; clutter_actor_set_size (ui->volume_low, icon_size, icon_size); clutter_actor_set_size (ui->volume_high, icon_size, icon_size); clutter_actor_set_size (ui->fullscreen_button, icon_size, icon_size); clutter_actor_set_size (ui->subtitle_toggle, icon_size, icon_size); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (ui->middle_box_layout), ctl_width * 0.04f); if (FALSE) { // hide this buttons (TODO: optional Flag) clutter_actor_set_size (ui->video_stream_toggle, icon_size, icon_size); clutter_actor_set_size (ui->audio_stream_toggle, icon_size, icon_size); } clutter_actor_get_size (CLUTTER_ACTOR (ui->main_box), &main_box_width, &main_box_height); main_box_horiz_pos = (control_box_width - main_box_width) / 2; main_box_vert_pos = (control_box_height - main_box_height) / 2; clutter_actor_set_position (CLUTTER_ACTOR (ui->main_box), main_box_horiz_pos, main_box_vert_pos); update_volume (ui, -1); } static gboolean update_volume (UserInterface * ui, gdouble volume) { if (volume == -1) g_object_get (G_OBJECT (ui->engine->player), "volume", &volume, NULL); ui->volume = (float) volume; clutter_content_invalidate (ui->vol_int_canvas); return TRUE; } /* -------------------- non-static functions --------------------- */ void interface_init (UserInterface * ui) { ui->filename = NULL; ui->fileuri = NULL; ui->play_png = NULL; ui->pause_png = NULL; ui->volume_low_png = NULL; ui->volume_high_png = NULL; ui->subtitle_active_png = NULL; ui->subtitle_inactive_png = NULL; ui->subtitles_available = FALSE; ui->video_stream_toggle_png = NULL; ui->audio_stream_toggle_png = NULL; ui->duration_str = NULL; ui->stage = NULL; ui->texture = NULL; ui->control_box = NULL; ui->control_bg = NULL; ui->control_title = NULL; ui->control_play_toggle = NULL; ui->control_seekbar = NULL; ui->control_pos = NULL; ui->volume_box = NULL; ui->volume_low = NULL; ui->volume_high = NULL; ui->vol_int = NULL; ui->vol_int_bg = NULL; ui->volume_point = NULL; ui->info_box = NULL; ui->main_box = NULL; ui->main_box_layout = NULL; ui->info_box_layout = NULL; ui->pos_n_vol_layout = NULL; ui->middle_box_layout = NULL; ui->engine = NULL; ui->screensaver = NULL; ui->playback_position = 0.0; ClutterColor stage_bg_color = { 0x00, 0x00, 0x00, 0xda }; ui->stage_bg_color = stage_bg_color; ClutterColor text_color = { 0xff, 0xff, 0xff, 0xff }; ui->text_color = text_color; ClutterColor border_color = { 0xff, 0xff, 0xff, 0x26 }; ui->border_color = border_color; ClutterColor gradient_start = { 0x3e, 0xb4, 0x8a, 0xff }; ui->gradient_start = gradient_start; ClutterColor gradient_finish = { 0x3e, 0xb4, 0x8a, 0xff }; ui->gradient_finish = gradient_finish; } gboolean interface_is_it_last (UserInterface * ui) { GList *element; element = g_list_find (ui->uri_list, ui->engine->uri); element = g_list_next (element); return (element == NULL); } gboolean interface_load_uri (UserInterface * ui, gchar * uri) { ui->fileuri = uri; ui->filename = g_path_get_basename (ui->fileuri); if (ui->stage != NULL) { gtk_window_set_title (GTK_WINDOW (ui->window), ui->filename); clutter_text_set_text (CLUTTER_TEXT (ui->control_title), ui->filename); } ui->duration_str = position_ns_to_str (ui->engine->media_duration); ui->media_width = ui->engine->media_width; ui->media_height = ui->engine->media_height; ui->windowed_width = ui->media_width; ui->windowed_height = ui->media_height; clutter_actor_set_size (CLUTTER_ACTOR (ui->texture), ui->media_width, ui->media_height); size_change (CLUTTER_STAGE (ui->stage), NULL, 0, ui); if (!ui->fullscreen) { ui->stage_width = ui->media_width; ui->stage_height = ui->media_height; gtk_widget_set_size_request (ui->clutter_widget, ui->stage_width / 2, ui->stage_height / 2); clutter_actor_set_size (CLUTTER_ACTOR (ui->stage), ui->stage_width, ui->stage_height); gtk_window_resize (GTK_WINDOW (ui->window), ui->stage_width, ui->stage_height); } if (!ui->penalty_box_active) show_controls (ui, TRUE); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (ui->control_play_toggle), gdk_pixbuf_new_from_file (ui->pause_png, NULL), NULL); return TRUE; } void interface_on_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x, gint y, GtkSelectionData * data, guint info, guint _time, UserInterface * ui) { char **list; list = g_uri_list_extract_uris (gtk_selection_data_get_data (data)); engine_open_uri (ui->engine, list[0]); interface_load_uri (ui, list[0]); engine_play (ui->engine); if (!CLUTTER_ACTOR_IS_VISIBLE (ui->texture)) { clutter_actor_show (ui->texture); } } void interface_play_next_or_prev (UserInterface * ui, gboolean next) { GList *element; gchar *uri; element = g_list_find (ui->uri_list, ui->engine->uri); if (next) element = g_list_next (element); else element = g_list_previous (element); if (element != NULL) { uri = element->data; engine_open_uri (ui->engine, uri); interface_load_uri (ui, uri); engine_play (ui->engine); } else { engine_seek (ui->engine, 0, TRUE); toggle_playing (ui); } } void interface_start (UserInterface * ui, gchar * uri) { GtkSettings *gtk_settings; GdkScreen *screen; g_print ("Loading ui!\n"); // Init UserInterface structure variables if (uri) { ui->fileuri = uri; ui->filename = g_path_get_basename (ui->fileuri); ui->media_width = ui->engine->media_width; ui->media_height = ui->engine->media_height; // Get screen size screen = gdk_screen_get_default (); ui->screen_width = gdk_screen_get_width (screen); ui->screen_height = gdk_screen_get_height (screen); if (ui->media_width < ui->screen_width && ui->media_height < ui->screen_height) { ui->stage_width = ui->media_width; ui->stage_height = ui->media_height; } else { // Media bigger than the screen gfloat aspect_ratio; aspect_ratio = (float) ui->media_width / ui->media_height; // Scale down to screen width proportionally ui->stage_width = ui->screen_width; ui->stage_height = ui->screen_width / aspect_ratio; if (ui->stage_height > ui->screen_height) { // Stage height still too big, scale down to screen height ui->stage_width = ui->screen_height * aspect_ratio; ui->stage_height = ui->screen_height; } } } else { ui->filename = ""; ui->media_width = DEFAULT_WIDTH; ui->media_height = DEFAULT_HEIGHT; ui->stage_width = DEFAULT_WIDTH; ui->stage_height = DEFAULT_HEIGHT; } /* Create the window and some child widgets: */ ui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); if (strcmp (ui->filename, "") != 0) gtk_window_set_title (GTK_WINDOW (ui->window), ui->filename); else gtk_window_set_title (GTK_WINDOW (ui->window), "snappy"); g_signal_connect (ui->window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_settings = gtk_settings_get_default (); g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL); ui->box = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (ui->box), GTK_ORIENTATION_VERTICAL); gtk_widget_set_hexpand (ui->box, TRUE); gtk_widget_set_vexpand (ui->box, TRUE); gtk_container_add (GTK_CONTAINER (ui->window), ui->box); /* Create the clutter widget: */ ui->clutter_widget = gtk_clutter_embed_new (); gtk_container_add (GTK_CONTAINER (ui->box), ui->clutter_widget); /* Get the stage */ ui->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (ui->clutter_widget)); clutter_actor_set_background_color (CLUTTER_ACTOR (ui->stage), &ui->stage_bg_color); /* Set the size of the widget, * because we should not set the size of its stage when using GtkClutterEmbed. */ gtk_widget_set_size_request (ui->clutter_widget, ui->stage_width / 2, ui->stage_height / 2); gtk_window_resize (GTK_WINDOW (ui->window), ui->stage_width, ui->stage_height); ui->controls_showing = FALSE; ui->keep_showing_controls = FALSE; ui->penalty_box_active = FALSE; ui->controls_timeout = -1; ui->seek_width = ui->stage_width / SEEK_WIDTH_RATIO; ui->seek_height = ui->stage_height / SEEK_HEIGHT_RATIO; ui->progress_id = -1; ui->title_length = TITLE_LENGTH; ui->media_duration = -1; ui->duration_str = position_ns_to_str (ui->engine->media_duration); clutter_actor_set_size (CLUTTER_ACTOR (ui->stage), ui->stage_width, ui->stage_height); clutter_stage_set_user_resizable (CLUTTER_STAGE (ui->stage), TRUE); if (ui->fullscreen) { gtk_window_fullscreen (GTK_WINDOW (ui->window)); } // Controls load_controls (ui); // Add video texture and control UI to stage clutter_actor_add_child (ui->stage, ui->texture); if (!ui->hide) { clutter_actor_add_child (ui->stage, CLUTTER_ACTOR (ui->control_box)); } clutter_actor_add_constraint (ui->texture, clutter_align_constraint_new (ui->stage, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (ui->texture, clutter_align_constraint_new (ui->stage, CLUTTER_ALIGN_Y_AXIS, 0.5)); clutter_actor_set_pivot_point (ui->texture, 0.5, 0.5); clutter_actor_animate (CLUTTER_ACTOR (ui->control_box), CLUTTER_EASE_OUT_QUINT, G_TIME_SPAN_MILLISECOND, "opacity", 0, NULL); /* Connect a signal handler to mouse clicks and key presses on the stage */ g_signal_connect (CLUTTER_STAGE (ui->stage), "allocation-changed", G_CALLBACK (size_change), ui); g_signal_connect (CLUTTER_STAGE (ui->stage), "event", G_CALLBACK (event_cb), ui); progress_timing (ui); ui->screensaver = screensaver_new (CLUTTER_STAGE (ui->stage)); screensaver_enable (ui->screensaver, FALSE); g_timeout_add (G_TIME_SPAN_MILLISECOND, progress_update_text, ui); if (!ui->blind) { /* Show the window */ gtk_widget_show_all (ui->window); } if (!ui->fileuri) { clutter_actor_hide (ui->texture); } gtk_drag_dest_set (GTK_WIDGET (ui->box), GTK_DEST_DEFAULT_ALL, drop_target_table, G_N_ELEMENTS (drop_target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect (G_OBJECT (ui->box), "drag_data_received", G_CALLBACK (interface_on_drop_cb), ui); } gboolean interface_update_controls (UserInterface * ui) { progress_update_text (ui); progress_update_seekbar (ui); update_volume (ui, -1); return TRUE; } snappy-0.3.7/src/user_interface.h000066400000000000000000000103111213407343700167710ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifndef __USER_INTERFACE_H__ #define __USER_INTERFACE_H__ #include #include "gst_engine.h" #include "screensaver.h" #define CTL_SHOW_SEC 3 #define CTL_FADE_DURATION G_TIME_SPAN_MILLISECOND / 4 #define CONTROLS_WIDTH_RATIO 0.48f #define CONTROLS_HEIGHT_RATIO 0.20f #define CONTROLS_ASPECT_RATIO 4.0f #define CONTROLS_MAX_WIDTH 480.0f #define CONTROLS_MIN_WIDTH 300.0f #define MAIN_BOX_W 0.95f #define MAIN_BOX_H 0.8f #define PLAY_TOGGLE_RATIO 0.38f #define TITLE_RATIO 0.033f #define SEEK_WIDTH_RATIO 0.9f #define SEEK_HEIGHT_RATIO 0.10f #define POS_RATIO 0.1f #define VOLUME_ICON_RATIO 0.18f #define VOLUME_WIDTH_RATIO 0.65f #define VOLUME_HEIGHT_RATIO 0.05f #define TITLE_LENGTH 40 #define SEC_IN_HOUR 3600 #define SEC_IN_MIN 60 #define PENALTY_TIME G_TIME_SPAN_MILLISECOND / 2 #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 480 G_BEGIN_DECLS enum { STREAM_AUDIO, STREAM_TEXT, STREAM_VIDEO }; typedef struct _UserInterface UserInterface; struct _UserInterface { gboolean controls_showing, keep_showing_controls; gboolean blind, fullscreen, hide, penalty_box_active, tags; gboolean subtitles_available; gint title_length, controls_timeout, progress_id; guint media_width, media_height; gint64 media_duration; gfloat stage_width, stage_height; gfloat screen_width, screen_height; gfloat windowed_width, windowed_height; gfloat playback_position, volume; gfloat seek_width, seek_height; gfloat volume_width, volume_height; gchar *filename, *fileuri; gchar *play_png, *pause_png; gchar *segment_png; gchar *volume_low_png, *volume_high_png; gchar *fullscreen_svg; gchar *subtitle_active_png, *subtitle_inactive_png; gchar *video_stream_toggle_png, *audio_stream_toggle_png; gchar *data_dir; gchar *duration_str; GList *uri_list; GtkWidget *window, *box, *clutter_widget; ClutterColor stage_bg_color, text_color, border_color; ClutterColor gradient_start, gradient_finish; ClutterActor *stage; ClutterActor *texture; ClutterActor *control_box; ClutterActor *control_bg, *control_title, *control_play_toggle; ClutterActor *control_seekbar; ClutterActor *control_pos; ClutterActor *volume_box; ClutterActor *volume_low, *volume_high; ClutterActor *fullscreen_button; ClutterActor *subtitle_toggle; ClutterActor *video_stream_toggle, *audio_stream_toggle; ClutterActor *vol_int, *vol_int_bg, *volume_point; ClutterActor *info_box; ClutterActor *pos_n_vol_box; ClutterActor *main_box; ClutterContent *seek_canvas; ClutterContent *vol_int_canvas; ClutterLayoutManager *main_box_layout; ClutterLayoutManager *info_box_layout; ClutterLayoutManager *pos_n_vol_layout; ClutterLayoutManager *middle_box_layout; GstEngine *engine; ScreenSaver *screensaver; }; static const GtkTargetEntry drop_target_table[] = { {(gchar *) "text/uri-list", 0, 0} }; // Declaration of non-static functions void interface_init (UserInterface * ui); gboolean interface_is_it_last (UserInterface * ui); gboolean interface_load_uri (UserInterface * ui, gchar * uri); void interface_on_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x, gint y, GtkSelectionData * data, guint info, guint _time, UserInterface * ui); void interface_play_next_or_prev (UserInterface * ui, gboolean next); void interface_start (UserInterface * ui, gchar * uri); gboolean interface_update_controls (UserInterface * ui); G_END_DECLS #endif /* __USER_INTERFACE_H__ */ snappy-0.3.7/src/utils.c000066400000000000000000000043671213407343700151440ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * Luis de Bethencourt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #include #include gchar * cut_long_filename (gchar * filename, gint length) { gchar *ret; gint c; gchar short_filename[length]; for (c = 0; filename[c] != '\0'; c++); if (c >= length) { for (c = 0; c < length; c++) { short_filename[c] = filename[c]; } short_filename[length] = '\0'; ret = g_filename_to_utf8 (short_filename, length, NULL, NULL, NULL); } else { ret = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL); } if (ret == NULL) g_print ("no filename. really?\n"); return ret; } gchar * clean_uri (gchar * input_arg) { GFile *gfile; gchar *fileuri; if (gst_uri_is_valid (input_arg)) fileuri = g_strdup (input_arg); else { gfile = g_file_new_for_commandline_arg (input_arg); if (g_file_has_uri_scheme (gfile, "archive") != FALSE) { g_print ("ERROR: %s isn't a file\n", input_arg); } fileuri = g_file_get_path (gfile); if (g_str_has_suffix (fileuri, ".iso")) { fileuri = g_strdup_printf ("dvd://%s", fileuri); } else { fileuri = g_strdup_printf ("file://%s", fileuri); } } return fileuri; } gchar * clean_brackets_in_uri (gchar * uri) { gchar *clean_uri; gchar **split; split = g_strsplit (uri, "[", 0); clean_uri = g_strjoinv (NULL, split); g_strfreev (split); split = g_strsplit (clean_uri, "]", 0); g_free (clean_uri); clean_uri = g_strjoinv (NULL, split); g_strfreev (split); return clean_uri; } snappy-0.3.7/src/utils.h000066400000000000000000000020221213407343700151330ustar00rootroot00000000000000/* * snappy - 0.3 * * Copyright (C) 2011-2013 Collabora Ltd. * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA */ #ifndef __UTILS_H__ #define __UTILS_H__ G_BEGIN_DECLS gchar * cut_long_filename (gchar * filename, gint length); gchar * clean_uri (gchar * input_arg); gchar * clean_brackets_in_uri (gchar * uri); G_END_DECLS #endif /* __UTILS_H__ */