Merging gst-examples

This commit is contained in:
Thibault Saunier 2021-09-24 16:15:54 -03:00
commit a7f54159b7
220 changed files with 31578 additions and 0 deletions

2
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,2 @@
include: "https://gitlab.freedesktop.org/gstreamer/gst-ci/raw/master/gitlab/ci_template.yml"

502
COPYING Normal file
View file

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

44
meson.build Normal file
View file

@ -0,0 +1,44 @@
project('gst-examples', 'c', version : '1.19.2', license : 'LGPL')
cc = meson.get_compiler('c')
m_dep = cc.find_library('m', required : false)
if cc.get_id() == 'msvc'
add_project_arguments(
cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
language : 'c')
endif
gst_version = meson.project_version()
version_arr = gst_version.split('.')
gst_version_major = version_arr[0].to_int()
gst_version_minor = version_arr[1].to_int()
gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
glib_dep = dependency('glib-2.0', version: '>= 2.38',
fallback: ['glib', 'libglib_dep'])
gio_dep = dependency('gio-2.0',
fallback: ['glib', 'libgio_dep'])
gobject_dep = dependency('gobject-2.0', version: '>= 2.38',
fallback: ['glib', 'libgobject_dep'])
gmodule_dep = dependency('gmodule-2.0',
fallback: ['glib', 'libgmodule_dep'])
gst_dep = dependency('gstreamer-1.0', version: gst_req,
fallback : ['gstreamer', 'gst_dep'])
gstplay_dep = dependency('gstreamer-play-1.0', version: gst_req,
fallback: ['gst-plugins-bad', 'gstplay_dep'])
gsttag_dep = dependency('gstreamer-tag-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'tag_dep'])
gstwebrtc_dep = dependency('gstreamer-webrtc-1.0', version: gst_req,
fallback: ['gst-plugins-bad', 'gstwebrtc_dep'])
gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
fallback : ['gst-plugins-base', 'sdp_dep'])
gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
fallback : ['gst-plugins-base', 'rtp_dep'])
subdir('playback')
subdir('network')
subdir('webrtc')

View file

@ -0,0 +1,542 @@
/*
* Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <gst/gst.h>
#include <gio/gio.h>
typedef struct
{
gchar *name;
GSocketConnection *connection;
GSocket *socket;
GInputStream *istream;
GOutputStream *ostream;
GSource *isource, *tosource;
GByteArray *current_message;
gchar *http_version;
gboolean waiting_200_ok;
} Client;
static const char *known_mimetypes[] = {
"video/webm",
"multipart/x-mixed-replace",
NULL
};
static GMainLoop *loop = NULL;
G_LOCK_DEFINE_STATIC (clients);
static GList *clients = NULL;
static GstElement *pipeline = NULL;
static GstElement *multisocketsink = NULL;
static gboolean started = FALSE;
static gchar *content_type;
G_LOCK_DEFINE_STATIC (caps);
static gboolean caps_resolved = FALSE;
static void
remove_client (Client * client)
{
gst_print ("Removing connection %s\n", client->name);
G_LOCK (clients);
clients = g_list_remove (clients, client);
G_UNLOCK (clients);
g_free (client->name);
g_free (client->http_version);
if (client->isource) {
g_source_destroy (client->isource);
g_source_unref (client->isource);
}
if (client->tosource) {
g_source_destroy (client->tosource);
g_source_unref (client->tosource);
}
g_object_unref (client->connection);
g_byte_array_unref (client->current_message);
g_slice_free (Client, client);
}
static void
write_bytes (Client * client, const gchar * data, guint len)
{
gssize w;
GError *err = NULL;
/* TODO: We assume this never blocks */
do {
w = g_output_stream_write (client->ostream, data, len, NULL, &err);
if (w > 0) {
len -= w;
data += w;
}
} while (w > 0 && len > 0);
if (w <= 0) {
if (err) {
gst_print ("Write error %s\n", err->message);
g_clear_error (&err);
}
remove_client (client);
}
}
static void
send_response_200_ok (Client * client)
{
gchar *response;
response = g_strdup_printf ("%s 200 OK\r\n%s\r\n", client->http_version,
content_type);
write_bytes (client, response, strlen (response));
g_free (response);
}
static void
send_response_404_not_found (Client * client)
{
gchar *response;
response = g_strdup_printf ("%s 404 Not Found\r\n\r\n", client->http_version);
write_bytes (client, response, strlen (response));
g_free (response);
}
static void
client_message (Client * client, const gchar * data, guint len)
{
gboolean http_head_request = FALSE;
gboolean http_get_request = FALSE;
gchar **lines = g_strsplit_set (data, "\r\n", -1);
if (g_str_has_prefix (lines[0], "HEAD"))
http_head_request = TRUE;
else if (g_str_has_prefix (lines[0], "GET"))
http_get_request = TRUE;
if (http_head_request || http_get_request) {
gchar **parts = g_strsplit (lines[0], " ", -1);
gboolean ok = FALSE;
g_free (client->http_version);
if (parts[1] && parts[2] && *parts[2] != '\0')
client->http_version = g_strdup (parts[2]);
else
client->http_version = g_strdup ("HTTP/1.0");
if (parts[1] && strcmp (parts[1], "/") == 0) {
G_LOCK (caps);
if (caps_resolved)
send_response_200_ok (client);
else
client->waiting_200_ok = TRUE;
G_UNLOCK (caps);
ok = TRUE;
} else {
send_response_404_not_found (client);
}
g_strfreev (parts);
if (ok) {
if (http_get_request) {
/* Start streaming to client socket */
g_source_destroy (client->isource);
g_source_unref (client->isource);
client->isource = NULL;
g_source_destroy (client->tosource);
g_source_unref (client->tosource);
client->tosource = NULL;
gst_print ("Starting to stream to %s\n", client->name);
g_signal_emit_by_name (multisocketsink, "add", client->socket);
}
if (!started) {
gst_print ("Starting pipeline\n");
if (gst_element_set_state (pipeline,
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
gst_print ("Failed to start pipeline\n");
g_main_loop_quit (loop);
}
started = TRUE;
}
}
} else {
gchar **parts = g_strsplit (lines[0], " ", -1);
gchar *response;
const gchar *http_version;
if (parts[1] && parts[2] && *parts[2] != '\0')
http_version = parts[2];
else
http_version = "HTTP/1.0";
response = g_strdup_printf ("%s 400 Bad Request\r\n\r\n", http_version);
write_bytes (client, response, strlen (response));
g_free (response);
g_strfreev (parts);
remove_client (client);
}
g_strfreev (lines);
}
static gboolean
on_timeout (Client * client)
{
gst_print ("Timeout\n");
remove_client (client);
return FALSE;
}
static gboolean
on_read_bytes (GPollableInputStream * stream, Client * client)
{
gssize r;
gchar data[4096];
GError *err = NULL;
do {
r = g_pollable_input_stream_read_nonblocking (G_POLLABLE_INPUT_STREAM
(client->istream), data, sizeof (data), NULL, &err);
if (r > 0)
g_byte_array_append (client->current_message, (guint8 *) data, r);
} while (r > 0);
if (r == 0) {
remove_client (client);
return FALSE;
} else if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
guint8 *tmp = client->current_message->data;
guint tmp_len = client->current_message->len;
g_clear_error (&err);
while (tmp_len > 3) {
if (tmp[0] == 0x0d && tmp[1] == 0x0a && tmp[2] == 0x0d && tmp[3] == 0x0a) {
guint len;
g_byte_array_append (client->current_message, (const guint8 *) "\0", 1);
len = tmp - client->current_message->data + 5;
client_message (client, (gchar *) client->current_message->data, len);
g_byte_array_remove_range (client->current_message, 0, len);
tmp = client->current_message->data;
tmp_len = client->current_message->len;
} else {
tmp++;
tmp_len--;
}
}
if (client->current_message->len >= 1024 * 1024) {
gst_print ("No complete request after 1MB of data\n");
remove_client (client);
return FALSE;
}
return TRUE;
} else {
gst_print ("Read error %s\n", err->message);
g_clear_error (&err);
remove_client (client);
return FALSE;
}
return FALSE;
}
static gboolean
on_new_connection (GSocketService * service, GSocketConnection * connection,
GObject * source_object, gpointer user_data)
{
Client *client = g_slice_new0 (Client);
GSocketAddress *addr;
GInetAddress *iaddr;
gchar *ip;
guint16 port;
addr = g_socket_connection_get_remote_address (connection, NULL);
iaddr = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (addr));
port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
ip = g_inet_address_to_string (iaddr);
client->name = g_strdup_printf ("%s:%u", ip, port);
g_free (ip);
g_object_unref (addr);
gst_print ("New connection %s\n", client->name);
client->waiting_200_ok = FALSE;
client->http_version = g_strdup ("");
client->connection = g_object_ref (connection);
client->socket = g_socket_connection_get_socket (connection);
client->istream =
g_io_stream_get_input_stream (G_IO_STREAM (client->connection));
client->ostream =
g_io_stream_get_output_stream (G_IO_STREAM (client->connection));
client->current_message = g_byte_array_sized_new (1024);
client->tosource = g_timeout_source_new_seconds (5);
g_source_set_callback (client->tosource, (GSourceFunc) on_timeout, client,
NULL);
g_source_attach (client->tosource, NULL);
client->isource =
g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM
(client->istream), NULL);
g_source_set_callback (client->isource, (GSourceFunc) on_read_bytes, client,
NULL);
g_source_attach (client->isource, NULL);
G_LOCK (clients);
clients = g_list_prepend (clients, client);
G_UNLOCK (clients);
return TRUE;
}
static gboolean
on_message (GstBus * bus, GstMessage * message, gpointer user_data)
{
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (message, &err, &debug);
gst_print ("Error %s\n", err->message);
g_error_free (err);
g_free (debug);
g_main_loop_quit (loop);
break;
}
case GST_MESSAGE_WARNING:{
gchar *debug;
GError *err;
gst_message_parse_warning (message, &err, &debug);
gst_print ("Warning %s\n", err->message);
g_error_free (err);
g_free (debug);
break;
}
case GST_MESSAGE_EOS:{
gst_print ("EOS\n");
g_main_loop_quit (loop);
}
default:
break;
}
return TRUE;
}
static void
on_client_socket_removed (GstElement * element, GSocket * socket,
gpointer user_data)
{
GList *l;
Client *client = NULL;
G_LOCK (clients);
for (l = clients; l; l = l->next) {
Client *tmp = l->data;
if (socket == tmp->socket) {
client = tmp;
break;
}
}
G_UNLOCK (clients);
if (client)
remove_client (client);
}
static void
on_stream_caps_changed (GObject * obj, GParamSpec * pspec, gpointer user_data)
{
GstPad *src_pad;
GstCaps *src_caps;
GstStructure *gstrc;
GList *l;
src_pad = (GstPad *) obj;
src_caps = gst_pad_get_current_caps (src_pad);
gstrc = gst_caps_get_structure (src_caps, 0);
/*
* Include a Content-type header in the case we know the mime
* type is OK in HTTP. Required for MJPEG streams.
*/
int i = 0;
const gchar *mimetype = gst_structure_get_name (gstrc);
while (known_mimetypes[i] != NULL) {
if (strcmp (mimetype, known_mimetypes[i]) == 0) {
if (content_type)
g_free (content_type);
/* Handle the (maybe not so) especial case of multipart to add boundary */
if (strcmp (mimetype, "multipart/x-mixed-replace") == 0 &&
gst_structure_has_field_typed (gstrc, "boundary", G_TYPE_STRING)) {
const gchar *boundary = gst_structure_get_string (gstrc, "boundary");
content_type = g_strdup_printf ("Content-Type: "
"multipart/x-mixed-replace;boundary=--%s\r\n", boundary);
} else {
content_type = g_strdup_printf ("Content-Type: %s\r\n", mimetype);
}
gst_print ("%s", content_type);
break;
}
i++;
}
gst_caps_unref (src_caps);
/* Send 200 OK to those clients waiting for it */
G_LOCK (caps);
caps_resolved = TRUE;
G_LOCK (clients);
for (l = clients; l; l = l->next) {
Client *cl = l->data;
if (cl->waiting_200_ok) {
send_response_200_ok (cl);
cl->waiting_200_ok = FALSE;
break;
}
}
G_UNLOCK (clients);
G_UNLOCK (caps);
}
int
main (gint argc, gchar ** argv)
{
GSocketService *service;
GstElement *bin, *stream;
GstPad *srcpad, *ghostpad, *sinkpad;
GError *err = NULL;
GstBus *bus;
gst_init (&argc, &argv);
if (argc < 4) {
gst_print ("usage: %s PORT <launch line>\n"
"example: %s 8080 ( videotestsrc ! theoraenc ! oggmux name=stream )\n",
argv[0], argv[0]);
return -1;
}
const gchar *port_str = argv[1];
const int port = (int) g_ascii_strtoll (port_str, NULL, 10);
bin = gst_parse_launchv ((const gchar **) argv + 2, &err);
if (!bin) {
gst_print ("invalid pipeline: %s\n", err->message);
g_clear_error (&err);
return -2;
}
stream = gst_bin_get_by_name (GST_BIN (bin), "stream");
if (!stream) {
gst_print ("no element with name \"stream\" found\n");
gst_object_unref (bin);
return -3;
}
srcpad = gst_element_get_static_pad (stream, "src");
if (!srcpad) {
gst_print ("no \"src\" pad in element \"stream\" found\n");
gst_object_unref (stream);
gst_object_unref (bin);
return -4;
}
content_type = g_strdup ("");
g_signal_connect (srcpad, "notify::caps",
G_CALLBACK (on_stream_caps_changed), NULL);
ghostpad = gst_ghost_pad_new ("src", srcpad);
gst_element_add_pad (GST_ELEMENT (bin), ghostpad);
gst_object_unref (srcpad);
pipeline = gst_pipeline_new (NULL);
multisocketsink = gst_element_factory_make ("multisocketsink", NULL);
g_object_set (multisocketsink,
"unit-format", GST_FORMAT_TIME,
"units-max", (gint64) 7 * GST_SECOND,
"units-soft-max", (gint64) 3 * GST_SECOND,
"recover-policy", 3 /* keyframe */ ,
"timeout", (guint64) 10 * GST_SECOND,
"sync-method", 1 /* next-keyframe */ ,
NULL);
gst_bin_add_many (GST_BIN (pipeline), bin, multisocketsink, NULL);
sinkpad = gst_element_get_static_pad (multisocketsink, "sink");
gst_pad_link (ghostpad, sinkpad);
gst_object_unref (sinkpad);
bus = gst_element_get_bus (pipeline);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message", G_CALLBACK (on_message), NULL);
gst_object_unref (bus);
g_signal_connect (multisocketsink, "client-socket-removed",
G_CALLBACK (on_client_socket_removed), NULL);
loop = g_main_loop_new (NULL, FALSE);
if (gst_element_set_state (pipeline,
GST_STATE_READY) == GST_STATE_CHANGE_FAILURE) {
gst_object_unref (pipeline);
g_main_loop_unref (loop);
gst_print ("Failed to set pipeline to ready\n");
return -5;
}
service = g_socket_service_new ();
g_socket_listener_add_inet_port (G_SOCKET_LISTENER (service), port, NULL,
NULL);
g_signal_connect (service, "incoming", G_CALLBACK (on_new_connection), NULL);
g_socket_service_start (service);
gst_print ("Listening on http://127.0.0.1:%d/\n", port);
g_main_loop_run (loop);
g_socket_service_stop (service);
g_object_unref (service);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
g_main_loop_unref (loop);
return 0;
}

View file

@ -0,0 +1 @@
executable('http-launch', 'http-launch.c', dependencies : [gst_dep, gio_dep])

1
network/meson.build Normal file
View file

@ -0,0 +1 @@
subdir('http-launch')

1
playback/meson.build Normal file
View file

@ -0,0 +1 @@
subdir('player')

2
playback/player/android/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.gradle
build/

View file

@ -0,0 +1,24 @@
# Android GStreamer sample player application
## Build and deploy
First of all you need to replace the gold linker with bfd in the `gst-android-1.14/armv7/share/gst-android/ndk-build/gstreamer-1.0.mk`
See also this [NDK issue](https://github.com/android-ndk/ndk/issues/337)
Then to build and deploy the player app to your device, use a command similar to:
```bash
$ GSTREAMER_ROOT_ANDROID=/path/to/gst-android-1.14/ PATH=~/dev/android/tools/bin:~/dev/android/ndk-bundle:$PATH ANDROID_HOME="$HOME/dev/android/" ./gradlew installDebug
```
## Run the application on the device
```bash
$ adb shell am start -n org.freedesktop.gstreamer.play/.Play http://ftp.nluug.nl/pub/graphics/blender/demo/movies/Sintel.2010.720p.mkv
```
To see the GStreamer logs at runtime:
```bash
$ adb logcat | egrep '(gst)'
```

View file

@ -0,0 +1,5 @@
.externalNativeBuild/
assets/
gst-build-*/
src/main/java/org/freedesktop/gstreamer/GStreamer.java
src/main/java/org/freedesktop/gstreamer/androidmedia/

View file

@ -0,0 +1,63 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "org.freedesktop.gstreamer.play"
minSdkVersion 15
targetSdkVersion 15
versionCode 1
versionName "1.0"
externalNativeBuild {
ndkBuild {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
gstRoot = project.gstAndroidRoot
else
gstRoot = System.env.GSTREAMER_ROOT_ANDROID
if (gstRoot == null)
throw new GradleException('GSTREAMER_ROOT_ANDROID must be set, or "gstAndroidRoot" must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=src/main/jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src/main/java", "GSTREAMER_ROOT_ANDROID=$gstRoot", "GSTREAMER_ASSETS_DIR=src/main/assets"
targets "gstplayer"
// All archs except MIPS and MIPS64 are supported
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
// x86_64 abis disabled because of https://bugzilla.gnome.org/show_bug.cgi?id=795454
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
afterEvaluate {
if (project.hasProperty('compileDebugJavaWithJavac'))
project.compileDebugJavaWithJavac.dependsOn 'externalNativeBuildDebug'
if (project.hasProperty('compileReleaseJavaWithJavac'))
project.compileReleaseJavaWithJavac.dependsOn 'externalNativeBuildRelease'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.1.1'
}

View file

@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/arun/code/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View file

@ -0,0 +1,344 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.freedesktop.gstreamer.play">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-feature android:glEsVersion="0x00020000"/>
<application android:theme="@style/Theme.AppCompat.Light" android:label="@string/app_name">
<activity android:name=".Play"
android:label="@string/app_name">
<!-- Files whose MIME type is known to Android -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:mimeType="image/*" />
<data android:mimeType="*/rmvb" />
<data android:mimeType="*/avi" />
<data android:mimeType="*/mkv" />
<data android:mimeType="application/3gpp*" />
<data android:mimeType="application/mp4" />
<data android:mimeType="application/mpeg*" />
<data android:mimeType="application/ogg" />
<data android:mimeType="application/sdp" />
<data android:mimeType="application/vnd.3gp*" />
<data android:mimeType="application/vnd.apple.mpegurl" />
<data android:mimeType="application/vnd.rn-realmedia*" />
<data android:mimeType="application/x-iso9660-image" />
<data android:mimeType="application/x-extension-mp4" />
<data android:mimeType="application/x-flac" />
<data android:mimeType="application/x-matroska" />
<data android:mimeType="application/x-mpegURL" />
<data android:mimeType="application/x-ogg" />
<data android:mimeType="application/x-quicktimeplayer" />
</intent-filter>
<!-- Files with unknown MIME type.
The list of extensions and supported protocols can certainly be extended. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:scheme="http" />
<data android:scheme="https" />
<!-- video -->
<data android:pathPattern=".*\\.3g2" />
<data android:pathPattern=".*\\.3gp" />
<data android:pathPattern=".*\\.3gp2" />
<data android:pathPattern=".*\\.3gpp" />
<data android:pathPattern=".*\\.amv" />
<data android:pathPattern=".*\\.asf" />
<data android:pathPattern=".*\\.avi" />
<data android:pathPattern=".*\\.divx" />
<data android:pathPattern=".*\\.drc" />
<data android:pathPattern=".*\\.dv" />
<data android:pathPattern=".*\\.f4v" />
<data android:pathPattern=".*\\.flv" />
<data android:pathPattern=".*\\.gvi" />
<data android:pathPattern=".*\\.gxf" />
<data android:pathPattern=".*\\.ismv" />
<data android:pathPattern=".*\\.iso" />
<data android:pathPattern=".*\\.m1v" />
<data android:pathPattern=".*\\.m2v" />
<data android:pathPattern=".*\\.m2t" />
<data android:pathPattern=".*\\.m2ts" />
<!-- <data android:pathPattern=".*\\.m3u" /> -->
<data android:pathPattern=".*\\.m3u8" />
<data android:pathPattern=".*\\.mkv" />
<data android:pathPattern=".*\\.mov" />
<data android:pathPattern=".*\\.mp2" />
<data android:pathPattern=".*\\.mp2v" />
<data android:pathPattern=".*\\.mp4" />
<data android:pathPattern=".*\\.mp4v" />
<data android:pathPattern=".*\\.mpe" />
<data android:pathPattern=".*\\.mpeg" />
<data android:pathPattern=".*\\.mpeg1" />
<data android:pathPattern=".*\\.mpeg2" />
<data android:pathPattern=".*\\.mpeg4" />
<data android:pathPattern=".*\\.mpg" />
<data android:pathPattern=".*\\.mpv2" />
<data android:pathPattern=".*\\.mts" />
<data android:pathPattern=".*\\.mtv" />
<data android:pathPattern=".*\\.mxf" />
<data android:pathPattern=".*\\.mxg" />
<data android:pathPattern=".*\\.nsv" />
<data android:pathPattern=".*\\.nut" />
<data android:pathPattern=".*\\.nuv" />
<data android:pathPattern=".*\\.ogm" />
<data android:pathPattern=".*\\.ogv" />
<data android:pathPattern=".*\\.ogx" />
<data android:pathPattern=".*\\.ps" />
<data android:pathPattern=".*\\.rec" />
<data android:pathPattern=".*\\.rm" />
<data android:pathPattern=".*\\.rmvb" />
<data android:pathPattern=".*\\.tod" />
<data android:pathPattern=".*\\.ts" />
<data android:pathPattern=".*\\.tts" />
<data android:pathPattern=".*\\.vob" />
<data android:pathPattern=".*\\.vro" />
<data android:pathPattern=".*\\.webm" />
<data android:pathPattern=".*\\.wm" />
<data android:pathPattern=".*\\.wmv" />
<data android:pathPattern=".*\\.wtv" />
<data android:pathPattern=".*\\.xesc" />
<data android:pathPattern=".*\\.3G2" />
<data android:pathPattern=".*\\.3GP" />
<data android:pathPattern=".*\\.3GP2" />
<data android:pathPattern=".*\\.3GPP" />
<data android:pathPattern=".*\\.AMV" />
<data android:pathPattern=".*\\.ASF" />
<data android:pathPattern=".*\\.AVI" />
<data android:pathPattern=".*\\.DIVX" />
<data android:pathPattern=".*\\.DRC" />
<data android:pathPattern=".*\\.DV" />
<data android:pathPattern=".*\\.F4V" />
<data android:pathPattern=".*\\.FLV" />
<data android:pathPattern=".*\\.GVI" />
<data android:pathPattern=".*\\.GXF" />
<data android:pathPattern=".*\\.ISMV" />
<data android:pathPattern=".*\\.ISO" />
<data android:pathPattern=".*\\.M1V" />
<data android:pathPattern=".*\\.M2V" />
<data android:pathPattern=".*\\.M2T" />
<data android:pathPattern=".*\\.M2TS" />
<!-- <data android:pathPattern=".*\\.M3U" /> -->
<data android:pathPattern=".*\\.M3U8" />
<data android:pathPattern=".*\\.MKV" />
<data android:pathPattern=".*\\.MOV" />
<data android:pathPattern=".*\\.MP2" />
<data android:pathPattern=".*\\.MP2V" />
<data android:pathPattern=".*\\.MP4" />
<data android:pathPattern=".*\\.MP4V" />
<data android:pathPattern=".*\\.MPE" />
<data android:pathPattern=".*\\.MPEG" />
<data android:pathPattern=".*\\.MPEG1" />
<data android:pathPattern=".*\\.MPEG2" />
<data android:pathPattern=".*\\.MPEG4" />
<data android:pathPattern=".*\\.MPG" />
<data android:pathPattern=".*\\.MPV2" />
<data android:pathPattern=".*\\.MTS" />
<data android:pathPattern=".*\\.MTV" />
<data android:pathPattern=".*\\.MXF" />
<data android:pathPattern=".*\\.MXG" />
<data android:pathPattern=".*\\.NSV" />
<data android:pathPattern=".*\\.NUT" />
<data android:pathPattern=".*\\.NUV" />
<data android:pathPattern=".*\\.OGM" />
<data android:pathPattern=".*\\.OGV" />
<data android:pathPattern=".*\\.OGX" />
<data android:pathPattern=".*\\.PS" />
<data android:pathPattern=".*\\.REC" />
<data android:pathPattern=".*\\.RM" />
<data android:pathPattern=".*\\.RMVB" />
<data android:pathPattern=".*\\.TOD" />
<data android:pathPattern=".*\\.TS" />
<data android:pathPattern=".*\\.TTS" />
<data android:pathPattern=".*\\.VOB" />
<data android:pathPattern=".*\\.VRO" />
<data android:pathPattern=".*\\.WEBM" />
<data android:pathPattern=".*\\.WM" />
<data android:pathPattern=".*\\.WMV" />
<data android:pathPattern=".*\\.WTV" />
<data android:pathPattern=".*\\.XESC" />
<!-- audio -->
<data android:pathPattern=".*\\.3ga" />
<data android:pathPattern=".*\\.a52" />
<data android:pathPattern=".*\\.aac" />
<data android:pathPattern=".*\\.ac3" />
<data android:pathPattern=".*\\.adt" />
<data android:pathPattern=".*\\.adts" />
<data android:pathPattern=".*\\.aif" />
<data android:pathPattern=".*\\.aifc" />
<data android:pathPattern=".*\\.aiff" />
<data android:pathPattern=".*\\.amr" />
<data android:pathPattern=".*\\.aob" />
<data android:pathPattern=".*\\.ape" />
<data android:pathPattern=".*\\.awb" />
<data android:pathPattern=".*\\.caf" />
<data android:pathPattern=".*\\.dts" />
<data android:pathPattern=".*\\.flac" />
<data android:pathPattern=".*\\.it" />
<data android:pathPattern=".*\\.m4a" />
<data android:pathPattern=".*\\.m4b" />
<data android:pathPattern=".*\\.m4p" />
<data android:pathPattern=".*\\.mid" />
<data android:pathPattern=".*\\.mka" />
<data android:pathPattern=".*\\.mlp" />
<data android:pathPattern=".*\\.mod" />
<data android:pathPattern=".*\\.mpa" />
<data android:pathPattern=".*\\.mp1" />
<data android:pathPattern=".*\\.mp2" />
<data android:pathPattern=".*\\.mp3" />
<data android:pathPattern=".*\\.mpc" />
<data android:pathPattern=".*\\.mpga" />
<data android:pathPattern=".*\\.oga" />
<data android:pathPattern=".*\\.ogg" />
<data android:pathPattern=".*\\.oma" />
<data android:pathPattern=".*\\.opus" />
<data android:pathPattern=".*\\.ra" />
<data android:pathPattern=".*\\.ram" />
<data android:pathPattern=".*\\.rmi" />
<data android:pathPattern=".*\\.s3m" />
<data android:pathPattern=".*\\.spx" />
<data android:pathPattern=".*\\.tta" />
<data android:pathPattern=".*\\.voc" />
<data android:pathPattern=".*\\.vqf" />
<data android:pathPattern=".*\\.w64" />
<data android:pathPattern=".*\\.wav" />
<data android:pathPattern=".*\\.wma" />
<data android:pathPattern=".*\\.wv" />
<data android:pathPattern=".*\\.xa" />
<data android:pathPattern=".*\\.xm" />
<data android:pathPattern=".*\\.3GA" />
<data android:pathPattern=".*\\.A52" />
<data android:pathPattern=".*\\.AAC" />
<data android:pathPattern=".*\\.AC3" />
<data android:pathPattern=".*\\.ADT" />
<data android:pathPattern=".*\\.ADTS" />
<data android:pathPattern=".*\\.AIF" />
<data android:pathPattern=".*\\.AIFC" />
<data android:pathPattern=".*\\.AIFF" />
<data android:pathPattern=".*\\.AMR" />
<data android:pathPattern=".*\\.AOB" />
<data android:pathPattern=".*\\.APE" />
<data android:pathPattern=".*\\.AWB" />
<data android:pathPattern=".*\\.CAF" />
<data android:pathPattern=".*\\.DTS" />
<data android:pathPattern=".*\\.FLAC" />
<data android:pathPattern=".*\\.IT" />
<data android:pathPattern=".*\\.M4A" />
<data android:pathPattern=".*\\.M4B" />
<data android:pathPattern=".*\\.M4P" />
<data android:pathPattern=".*\\.MID" />
<data android:pathPattern=".*\\.MKA" />
<data android:pathPattern=".*\\.MLP" />
<data android:pathPattern=".*\\.MOD" />
<data android:pathPattern=".*\\.MPA" />
<data android:pathPattern=".*\\.MP1" />
<data android:pathPattern=".*\\.MP2" />
<data android:pathPattern=".*\\.MP3" />
<data android:pathPattern=".*\\.MPC" />
<data android:pathPattern=".*\\.MPGA" />
<data android:pathPattern=".*\\.OGA" />
<data android:pathPattern=".*\\.OGG" />
<data android:pathPattern=".*\\.OMA" />
<data android:pathPattern=".*\\.OPUS" />
<data android:pathPattern=".*\\.RA" />
<data android:pathPattern=".*\\.RAM" />
<data android:pathPattern=".*\\.RMI" />
<data android:pathPattern=".*\\.S3M" />
<data android:pathPattern=".*\\.SPX" />
<data android:pathPattern=".*\\.TTA" />
<data android:pathPattern=".*\\.VOC" />
<data android:pathPattern=".*\\.VQF" />
<data android:pathPattern=".*\\.W64" />
<data android:pathPattern=".*\\.WAV" />
<data android:pathPattern=".*\\.WMA" />
<data android:pathPattern=".*\\.WV" />
<data android:pathPattern=".*\\.XA" />
<data android:pathPattern=".*\\.XM" />
</intent-filter>
<!-- Remote URI schemes without types -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="rtmp" />
<data android:scheme="rtmpt" />
<data android:scheme="rtmps" />
<data android:scheme="rtmpe" />
<data android:scheme="rtmfp" />
<data android:scheme="rtmpte" />
<data android:scheme="rtmpts" />
<data android:scheme="rtsp" />
<data android:scheme="rtspu" />
<data android:scheme="rtspt" />
<data android:scheme="rtsph" />
<data android:scheme="rtsp-sdp" />
<data android:scheme="rtsps" />
<data android:scheme="rtspsu" />
<data android:scheme="rtspst" />
<data android:scheme="rtspsh" />
<data android:scheme="mms" />
<data android:scheme="mmsh" />
<data android:scheme="mmst" />
<data android:scheme="mmsu" />
<data android:scheme="icy" />
<data android:scheme="icyx" />
<data android:scheme="udp" />
</intent-filter>
<!-- Remote URI schemes with types -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<data android:mimeType="image/*" />
<data android:scheme="rtmp" />
<data android:scheme="rtmpt" />
<data android:scheme="rtmps" />
<data android:scheme="rtmpe" />
<data android:scheme="rtmfp" />
<data android:scheme="rtmpte" />
<data android:scheme="rtmpts" />
<data android:scheme="rtsp" />
<data android:scheme="rtspu" />
<data android:scheme="rtspt" />
<data android:scheme="rtsph" />
<data android:scheme="rtsp-sdp" />
<data android:scheme="rtsps" />
<data android:scheme="rtspsu" />
<data android:scheme="rtspst" />
<data android:scheme="rtspsh" />
<data android:scheme="mms" />
<data android:scheme="mmsh" />
<data android:scheme="mmst" />
<data android:scheme="mmsu" />
<data android:scheme="icy" />
<data android:scheme="icyx" />
<data android:scheme="udp" />
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -0,0 +1,241 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package org.freedesktop.gstreamer;
import java.io.Closeable;
import android.view.Surface;
import android.content.Context;
import org.freedesktop.gstreamer.GStreamer;
public class Player implements Closeable {
private static native void nativeClassInit();
public static void init(Context context) throws Exception {
System.loadLibrary("gstreamer_android");
GStreamer.init(context);
System.loadLibrary("gstplayer");
nativeClassInit();
}
private long native_player;
private native void nativeNew();
public Player() {
nativeNew();
}
private native void nativeFree();
@Override
public void close() {
nativeFree();
}
private native void nativePlay();
public void play() {
nativePlay();
}
private native void nativePause();
public void pause() {
nativePause();
}
private native void nativeStop();
public void stop() {
nativeStop();
}
private native void nativeSeek(long position);
public void seek(long position) {
nativeSeek(position);
}
private native String nativeGetUri();
public String getUri() {
return nativeGetUri();
}
private native void nativeSetUri(String uri);
public void setUri(String uri) {
nativeSetUri(uri);
}
private native long nativeGetPosition();
public long getPosition() {
return nativeGetPosition();
}
private native long nativeGetDuration();
public long getDuration() {
return nativeGetDuration();
}
private native double nativeGetVolume();
public double getVolume() {
return nativeGetVolume();
}
private native void nativeSetVolume(double volume);
public void setVolume(double volume) {
nativeSetVolume(volume);
}
private native boolean nativeGetMute();
public boolean getMute() {
return nativeGetMute();
}
private native void nativeSetMute(boolean mute);
public void setMute(boolean mute) {
nativeSetMute(mute);
}
private Surface surface;
private native void nativeSetSurface(Surface surface);
public void setSurface(Surface surface) {
this.surface = surface;
nativeSetSurface(surface);
}
public Surface getSurface() {
return surface;
}
public static interface PositionUpdatedListener {
abstract void positionUpdated(Player player, long position);
}
private PositionUpdatedListener positionUpdatedListener;
public void setPositionUpdatedListener(PositionUpdatedListener listener) {
positionUpdatedListener = listener;
}
private void onPositionUpdated(long position) {
if (positionUpdatedListener != null) {
positionUpdatedListener.positionUpdated(this, position);
}
}
public static interface DurationChangedListener {
abstract void durationChanged(Player player, long duration);
}
private DurationChangedListener durationChangedListener;
public void setDurationChangedListener(DurationChangedListener listener) {
durationChangedListener = listener;
}
private void onDurationChanged(long duration) {
if (durationChangedListener != null) {
durationChangedListener.durationChanged(this, duration);
}
}
private static final State[] stateMap = {State.STOPPED, State.BUFFERING, State.PAUSED, State.PLAYING};
public enum State {
STOPPED,
BUFFERING,
PAUSED,
PLAYING
}
public static interface StateChangedListener {
abstract void stateChanged(Player player, State state);
}
private StateChangedListener stateChangedListener;
public void setStateChangedListener(StateChangedListener listener) {
stateChangedListener = listener;
}
private void onStateChanged(int stateIdx) {
if (stateChangedListener != null) {
State state = stateMap[stateIdx];
stateChangedListener.stateChanged(this, state);
}
}
public static interface BufferingListener {
abstract void buffering(Player player, int percent);
}
private BufferingListener bufferingListener;
public void setBufferingListener(BufferingListener listener) {
bufferingListener = listener;
}
private void onBuffering(int percent) {
if (bufferingListener != null) {
bufferingListener.buffering(this, percent);
}
}
public static interface EndOfStreamListener {
abstract void endOfStream(Player player);
}
private EndOfStreamListener endOfStreamListener;
public void setEndOfStreamListener(EndOfStreamListener listener) {
endOfStreamListener = listener;
}
private void onEndOfStream() {
if (endOfStreamListener != null) {
endOfStreamListener.endOfStream(this);
}
}
// Keep these in sync with gstplayer.h
private static final Error[] errorMap = {Error.FAILED};
public enum Error {
FAILED
}
public static interface ErrorListener {
abstract void error(Player player, Error error, String errorMessage);
}
private ErrorListener errorListener;
public void setErrorListener(ErrorListener listener) {
errorListener = listener;
}
private void onError(int errorCode, String errorMessage) {
if (errorListener != null) {
Error error = errorMap[errorCode];
errorListener.error(this, error, errorMessage);
}
}
public static interface VideoDimensionsChangedListener {
abstract void videoDimensionsChanged(Player player, int width, int height);
}
private VideoDimensionsChangedListener videoDimensionsChangedListener;
public void setVideoDimensionsChangedListener(VideoDimensionsChangedListener listener) {
videoDimensionsChangedListener = listener;
}
private void onVideoDimensionsChanged(int width, int height) {
if (videoDimensionsChangedListener != null) {
videoDimensionsChangedListener.videoDimensionsChanged(this, width, height);
}
}
}

View file

@ -0,0 +1,110 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package org.freedesktop.gstreamer.play;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
// A simple SurfaceView whose width and height can be set from the outside
public class GStreamerSurfaceView extends SurfaceView {
public int media_width = 320;
public int media_height = 240;
// Mandatory constructors, they do not do much
public GStreamerSurfaceView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public GStreamerSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public GStreamerSurfaceView (Context context) {
super(context);
}
// Called by the layout manager to find out our size and give us some rules.
// We will try to maximize our size, and preserve the media's aspect ratio if
// we are given the freedom to do so.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (media_width == 0 || media_height == 0) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
int width = 0, height = 0;
int wmode = View.MeasureSpec.getMode(widthMeasureSpec);
int hmode = View.MeasureSpec.getMode(heightMeasureSpec);
int wsize = View.MeasureSpec.getSize(widthMeasureSpec);
int hsize = View.MeasureSpec.getSize(heightMeasureSpec);
Log.i ("GStreamer", "onMeasure called with " + media_width + "x" + media_height);
// Obey width rules
switch (wmode) {
case View.MeasureSpec.AT_MOST:
if (hmode == View.MeasureSpec.EXACTLY) {
width = Math.min(hsize * media_width / media_height, wsize);
break;
}
case View.MeasureSpec.EXACTLY:
width = wsize;
break;
case View.MeasureSpec.UNSPECIFIED:
width = media_width;
}
// Obey height rules
switch (hmode) {
case View.MeasureSpec.AT_MOST:
if (wmode == View.MeasureSpec.EXACTLY) {
height = Math.min(wsize * media_height / media_width, hsize);
break;
}
case View.MeasureSpec.EXACTLY:
height = hsize;
break;
case View.MeasureSpec.UNSPECIFIED:
height = media_height;
}
// Finally, calculate best size when both axis are free
if (hmode == View.MeasureSpec.AT_MOST && wmode == View.MeasureSpec.AT_MOST) {
int correct_height = width * media_height / media_width;
int correct_width = height * media_width / media_height;
if (correct_height < height)
height = correct_height;
else
width = correct_width;
}
// Obey minimum size
width = Math.max (getSuggestedMinimumWidth(), width);
height = Math.max (getSuggestedMinimumHeight(), height);
setMeasuredDimension(width, height);
}
}

View file

@ -0,0 +1,197 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
package org.freedesktop.gstreamer.play;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.support.v7.app.AppCompatActivity;
import org.freedesktop.gstreamer.Player;
public class Play extends AppCompatActivity implements SurfaceHolder.Callback, OnSeekBarChangeListener {
private PowerManager.WakeLock wake_lock;
private Player player;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try {
Player.init(this);
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
finish();
return;
}
setContentView(R.layout.main);
player = new Player();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wake_lock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GStreamer Play");
wake_lock.setReferenceCounted(false);
ImageButton play = (ImageButton) this.findViewById(R.id.button_play);
play.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
player.play();
wake_lock.acquire();
}
});
ImageButton pause = (ImageButton) this.findViewById(R.id.button_pause);
pause.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
player.pause();
wake_lock.release();
}
});
final SeekBar sb = (SeekBar) this.findViewById(R.id.seek_bar);
sb.setOnSeekBarChangeListener(this);
player.setPositionUpdatedListener(new Player.PositionUpdatedListener() {
public void positionUpdated(Player player, final long position) {
runOnUiThread (new Runnable() {
public void run() {
sb.setProgress((int) (position / 1000000));
updateTimeWidget();
}
});
}
});
player.setDurationChangedListener(new Player.DurationChangedListener() {
public void durationChanged(Player player, final long duration) {
runOnUiThread (new Runnable() {
public void run() {
sb.setMax((int) (duration / 1000000));
updateTimeWidget();
}
});
}
});
final GStreamerSurfaceView gsv = (GStreamerSurfaceView) this.findViewById(R.id.surface_video);
player.setVideoDimensionsChangedListener(new Player.VideoDimensionsChangedListener() {
public void videoDimensionsChanged(Player player, final int width, final int height) {
runOnUiThread (new Runnable() {
public void run() {
Log.i ("GStreamer", "Media size changed to " + width + "x" + height);
gsv.media_width = width;
gsv.media_height = height;
runOnUiThread(new Runnable() {
public void run() {
gsv.requestLayout();
}
});
}
});
}
});
SurfaceHolder sh = gsv.getHolder();
sh.addCallback(this);
String mediaUri = null;
Intent intent = getIntent();
android.net.Uri uri = intent.getData();
Log.i ("GStreamer", "Received URI: " + uri);
if (uri != null) {
if (uri.getScheme().equals("content")) {
android.database.Cursor cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
mediaUri = "file://" + cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Video.Media.DATA));
cursor.close();
} else {
mediaUri = uri.toString();
}
player.setUri(mediaUri);
}
updateTimeWidget();
}
protected void onDestroy() {
player.close();
super.onDestroy();
}
private void updateTimeWidget () {
final TextView tv = (TextView) this.findViewById(R.id.textview_time);
final SeekBar sb = (SeekBar) this.findViewById(R.id.seek_bar);
final int pos = sb.getProgress();
final int max = sb.getMax();
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
final String message = df.format(new Date (pos)) + " / " + df.format(new Date (max));
tv.setText(message);
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
Log.d("GStreamer", "Surface changed to format " + format + " width "
+ width + " height " + height);
player.setSurface(holder.getSurface());
}
public void surfaceCreated(SurfaceHolder holder) {
Log.d("GStreamer", "Surface created: " + holder.getSurface());
}
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d("GStreamer", "Surface destroyed");
player.setSurface(null);
}
public void onProgressChanged(SeekBar sb, int progress, boolean fromUser) {
if (!fromUser) return;
updateTimeWidget();
}
public void onStartTrackingTouch(SeekBar sb) {
}
public void onStopTrackingTouch(SeekBar sb) {
Log.d("GStreamer", "Seek to " + sb.getProgress());
player.seek(((long) sb.getProgress()) * 1000000);
}
}

View file

@ -0,0 +1,46 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gstplayer
LOCAL_SRC_FILES := player.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_SHARED_LIBRARY)
ifndef GSTREAMER_ROOT_ANDROID
$(error GSTREAMER_ROOT_ANDROID is not defined!)
endif
ifeq ($(TARGET_ARCH_ABI),armeabi)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/arm
else ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/armv7
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/arm64
else ifeq ($(TARGET_ARCH_ABI),x86)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/x86
else ifeq ($(TARGET_ARCH_ABI),x86_64)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/x86_64
else
$(error Target arch ABI not supported: $(TARGET_ARCH_ABI))
endif
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) \
$(GSTREAMER_PLUGINS_PLAYBACK) \
$(GSTREAMER_PLUGINS_CODECS) \
$(GSTREAMER_PLUGINS_NET) \
$(GSTREAMER_PLUGINS_SYS) \
$(GSTREAMER_PLUGINS_CODECS_RESTRICTED) \
$(GSTREAMER_CODECS_GPL) \
$(GSTREAMER_PLUGINS_ENCODING) \
$(GSTREAMER_PLUGINS_VIS) \
$(GSTREAMER_PLUGINS_EFFECTS) \
$(GSTREAMER_PLUGINS_NET_RESTRICTED)
GSTREAMER_EXTRA_DEPS := gstreamer-player-1.0 gstreamer-video-1.0 glib-2.0
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer-1.0.mk

View file

@ -0,0 +1,2 @@
APP_PLATFORM = 15
APP_ABI = armeabi armeabi-v7a arm64-v8a x86 x86_64

View file

@ -0,0 +1,500 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <string.h>
#include <stdint.h>
#include <jni.h>
#include <android/log.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <gst/player/gstplayer.h>
#include <gst/player/gstplayer-video-overlay-video-renderer.h>
GST_DEBUG_CATEGORY_STATIC (debug_category);
#define GST_CAT_DEFAULT debug_category
#define GET_CUSTOM_DATA(env, thiz, fieldID) (Player *)(gintptr)(*env)->GetLongField (env, thiz, fieldID)
#define SET_CUSTOM_DATA(env, thiz, fieldID, data) (*env)->SetLongField (env, thiz, fieldID, (jlong)(gintptr)data)
typedef struct _Player
{
jobject java_player;
GstPlayer *player;
GstPlayerVideoRenderer *renderer;
ANativeWindow *native_window;
} Player;
static pthread_key_t current_jni_env;
static JavaVM *java_vm;
static jfieldID native_player_field_id;
static jmethodID on_position_updated_method_id;
static jmethodID on_duration_changed_method_id;
static jmethodID on_state_changed_method_id;
static jmethodID on_buffering_method_id;
static jmethodID on_end_of_stream_method_id;
static jmethodID on_error_method_id;
static jmethodID on_video_dimensions_changed_method_id;
/* Register this thread with the VM */
static JNIEnv *
attach_current_thread (void)
{
JNIEnv *env;
JavaVMAttachArgs args;
GST_DEBUG ("Attaching thread %p", g_thread_self ());
args.version = JNI_VERSION_1_4;
args.name = NULL;
args.group = NULL;
if ((*java_vm)->AttachCurrentThread (java_vm, &env, &args) < 0) {
GST_ERROR ("Failed to attach current thread");
return NULL;
}
return env;
}
/* Unregister this thread from the VM */
static void
detach_current_thread (void *env)
{
GST_DEBUG ("Detaching thread %p", g_thread_self ());
(*java_vm)->DetachCurrentThread (java_vm);
}
/* Retrieve the JNI environment for this thread */
static JNIEnv *
get_jni_env (void)
{
JNIEnv *env;
if ((env = pthread_getspecific (current_jni_env)) == NULL) {
env = attach_current_thread ();
pthread_setspecific (current_jni_env, env);
}
return env;
}
/*
* Java Bindings
*/
static void
on_position_updated (GstPlayer * unused, GstClockTime position, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_position_updated_method_id, position);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_duration_changed (GstPlayer * unused, GstClockTime duration, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_duration_changed_method_id, duration);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_state_changed (GstPlayer * unused, GstPlayerState state, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_state_changed_method_id, state);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_buffering (GstPlayer * unused, gint percent, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_buffering_method_id, percent);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_end_of_stream (GstPlayer * unused, Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player, on_end_of_stream_method_id);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
on_error (GstPlayer * unused, GError * err, Player * player)
{
JNIEnv *env = get_jni_env ();
jstring error_msg;
error_msg = (*env)->NewStringUTF (env, err->message);
(*env)->CallVoidMethod (env, player->java_player, on_error_method_id,
err->code, error_msg);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
(*env)->DeleteLocalRef (env, error_msg);
}
static void
on_video_dimensions_changed (GstPlayer * unused, gint width, gint height,
Player * player)
{
JNIEnv *env = get_jni_env ();
(*env)->CallVoidMethod (env, player->java_player,
on_video_dimensions_changed_method_id, width, height);
if ((*env)->ExceptionCheck (env)) {
(*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
}
}
static void
native_new (JNIEnv * env, jobject thiz)
{
Player *player = g_new0 (Player, 1);
player->renderer = gst_player_video_overlay_video_renderer_new (NULL);
player->player = gst_player_new (player->renderer, NULL);
SET_CUSTOM_DATA (env, thiz, native_player_field_id, player);
player->java_player = (*env)->NewGlobalRef (env, thiz);
g_signal_connect (player->player, "position-updated",
G_CALLBACK (on_position_updated), player);
g_signal_connect (player->player, "duration-changed",
G_CALLBACK (on_duration_changed), player);
g_signal_connect (player->player, "state-changed",
G_CALLBACK (on_state_changed), player);
g_signal_connect (player->player, "buffering",
G_CALLBACK (on_buffering), player);
g_signal_connect (player->player, "end-of-stream",
G_CALLBACK (on_end_of_stream), player);
g_signal_connect (player->player, "error", G_CALLBACK (on_error), player);
g_signal_connect (player->player, "video-dimensions-changed",
G_CALLBACK (on_video_dimensions_changed), player);
}
static void
native_free (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
g_object_unref (player->player);
(*env)->DeleteGlobalRef (env, player->java_player);
g_free (player);
SET_CUSTOM_DATA (env, thiz, native_player_field_id, NULL);
}
static void
native_play (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_play (player->player);
}
static void
native_pause (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_pause (player->player);
}
static void
native_stop (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_stop (player->player);
}
static void
native_seek (JNIEnv * env, jobject thiz, jlong position)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
gst_player_seek (player->player, position);
}
static void
native_set_uri (JNIEnv * env, jobject thiz, jobject uri)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
const gchar *uri_str;
if (!player)
return;
uri_str = (*env)->GetStringUTFChars (env, uri, NULL);
g_object_set (player->player, "uri", uri_str, NULL);
(*env)->ReleaseStringUTFChars (env, uri, uri_str);
}
static jobject
native_get_uri (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jobject uri;
gchar *uri_str;
if (!player)
return NULL;
g_object_get (player->player, "uri", &uri_str, NULL);
uri = (*env)->NewStringUTF (env, uri_str);
g_free (uri_str);
return uri;
}
static jlong
native_get_position (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jdouble position;
if (!player)
return -1;
g_object_get (player->player, "position", &position, NULL);
return position;
}
static jlong
native_get_duration (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jlong duration;
if (!player)
return -1;
g_object_get (player->player, "duration", &duration, NULL);
return duration;
}
static jdouble
native_get_volume (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jdouble volume;
if (!player)
return 1.0;
g_object_get (player->player, "volume", &volume, NULL);
return volume;
}
static void
native_set_volume (JNIEnv * env, jobject thiz, jdouble volume)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
g_object_set (player->player, "volume", volume, NULL);
}
static jboolean
native_get_mute (JNIEnv * env, jobject thiz)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
jboolean mute;
if (!player)
return FALSE;
g_object_get (player->player, "mute", &mute, NULL);
return mute;
}
static void
native_set_mute (JNIEnv * env, jobject thiz, jboolean mute)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
if (!player)
return;
g_object_set (player->player, "mute", mute, NULL);
}
static void
native_set_surface (JNIEnv * env, jobject thiz, jobject surface)
{
Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id);
ANativeWindow *new_native_window;
if (!player)
return;
new_native_window = surface ? ANativeWindow_fromSurface (env, surface) : NULL;
GST_DEBUG ("Received surface %p (native window %p)", surface,
new_native_window);
if (player->native_window) {
ANativeWindow_release (player->native_window);
}
player->native_window = new_native_window;
gst_player_video_overlay_video_renderer_set_window_handle
(GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (player->renderer),
(gpointer) new_native_window);
gst_player_video_overlay_video_renderer_expose
(GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (player->renderer));
}
static void
native_class_init (JNIEnv * env, jclass klass)
{
native_player_field_id =
(*env)->GetFieldID (env, klass, "native_player", "J");
on_position_updated_method_id =
(*env)->GetMethodID (env, klass, "onPositionUpdated", "(J)V");
on_duration_changed_method_id =
(*env)->GetMethodID (env, klass, "onDurationChanged", "(J)V");
on_state_changed_method_id =
(*env)->GetMethodID (env, klass, "onStateChanged", "(I)V");
on_buffering_method_id =
(*env)->GetMethodID (env, klass, "onBuffering", "(I)V");
on_end_of_stream_method_id =
(*env)->GetMethodID (env, klass, "onEndOfStream", "()V");
on_error_method_id =
(*env)->GetMethodID (env, klass, "onError", "(ILjava/lang/String;)V");
on_video_dimensions_changed_method_id =
(*env)->GetMethodID (env, klass, "onVideoDimensionsChanged", "(II)V");
if (!native_player_field_id ||
!on_position_updated_method_id || !on_duration_changed_method_id ||
!on_state_changed_method_id || !on_buffering_method_id ||
!on_end_of_stream_method_id ||
!on_error_method_id || !on_video_dimensions_changed_method_id) {
static const gchar *message =
"The calling class does not implement all necessary interface methods";
jclass exception_class = (*env)->FindClass (env, "java/lang/Exception");
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer", "%s", message);
(*env)->ThrowNew (env, exception_class, message);
}
gst_debug_set_threshold_for_name ("gst-player", GST_LEVEL_TRACE);
}
/* List of implemented native methods */
static JNINativeMethod native_methods[] = {
{"nativeClassInit", "()V", (void *) native_class_init},
{"nativeNew", "()V", (void *) native_new},
{"nativePlay", "()V", (void *) native_play},
{"nativePause", "()V", (void *) native_pause},
{"nativeStop", "()V", (void *) native_stop},
{"nativeSeek", "(J)V", (void *) native_seek},
{"nativeFree", "()V", (void *) native_free},
{"nativeGetUri", "()Ljava/lang/String;", (void *) native_get_uri},
{"nativeSetUri", "(Ljava/lang/String;)V", (void *) native_set_uri},
{"nativeGetPosition", "()J", (void *) native_get_position},
{"nativeGetDuration", "()J", (void *) native_get_duration},
{"nativeGetVolume", "()D", (void *) native_get_volume},
{"nativeSetVolume", "(D)V", (void *) native_set_volume},
{"nativeGetMute", "()Z", (void *) native_get_mute},
{"nativeSetMute", "(Z)V", (void *) native_set_mute},
{"nativeSetSurface", "(Landroid/view/Surface;)V",
(void *) native_set_surface}
};
/* Library initializer */
jint
JNI_OnLoad (JavaVM * vm, void *reserved)
{
JNIEnv *env = NULL;
java_vm = vm;
if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) {
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer",
"Could not retrieve JNIEnv");
return 0;
}
jclass klass = (*env)->FindClass (env, "org/freedesktop/gstreamer/Player");
if (!klass) {
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer",
"Could not retrieve class org.freedesktop.gstreamer.Player");
return 0;
}
if ((*env)->RegisterNatives (env, klass, native_methods,
G_N_ELEMENTS (native_methods))) {
__android_log_print (ANDROID_LOG_ERROR, "GstPlayer",
"Could not register native methods for org.freedesktop.gstreamer.Player");
return 0;
}
pthread_key_create (&current_jni_env, detach_current_thread);
return JNI_VERSION_1_4;
}

View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/button_play"
android:src="@android:drawable/ic_media_play"
android:text="@string/button_play" />
<ImageButton
android:id="@+id/button_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/button_pause"
android:src="@android:drawable/ic_media_pause"
android:text="@string/button_pause" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="@+id/textview_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" />
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:indeterminate="false" />
</LinearLayout>
<org.freedesktop.gstreamer.play.GStreamerSurfaceView
android:id="@+id/surface_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
</LinearLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GStreamer Play</string>
<string name="button_play">Play</string>
<string name="button_pause">Pause</string>
</resources>

View file

@ -0,0 +1,25 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View file

@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# gstAndroidRoot can be set to point to the unpacked GStreamer android top-level directory
# containing each architecture in subdirectories, or else set the GSTREAMER_ROOT_ANDROID
# environment variable to that location
# gstAndroidRoot=/path/to/gstreamer/android

Binary file not shown.

View file

@ -0,0 +1,6 @@
#Sat Apr 21 19:58:19 WEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

160
playback/player/android/gradlew vendored Executable file
View file

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
playback/player/android/gradlew.bat vendored Normal file
View file

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1 @@
include ':app'

View file

@ -0,0 +1,143 @@
/* GStreamer command line playback testing utility - keyboard handling helpers
*
* Copyright (C) 2013 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2013 Centricular Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gst-play-kb.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <termios.h>
#endif
#include <gst/gst.h>
/* This is all not thread-safe, but doesn't have to be really */
#ifdef G_OS_UNIX
static struct termios term_settings;
static gboolean term_settings_saved = FALSE;
static GstPlayKbFunc kb_callback;
static gpointer kb_callback_data;
static gulong io_watch_id;
static gboolean
gst_play_kb_io_cb (GIOChannel * ioc, GIOCondition cond, gpointer user_data)
{
GIOStatus status;
if (cond & G_IO_IN) {
gchar buf[16] = { 0, };
gsize read;
status = g_io_channel_read_chars (ioc, buf, sizeof (buf) - 1, &read, NULL);
if (status == G_IO_STATUS_ERROR)
return FALSE;
if (status == G_IO_STATUS_NORMAL) {
if (kb_callback)
kb_callback (buf, kb_callback_data);
}
}
return TRUE; /* call us again */
}
gboolean
gst_play_kb_set_key_handler (GstPlayKbFunc kb_func, gpointer user_data)
{
GIOChannel *ioc;
int flags;
if (!isatty (STDIN_FILENO)) {
GST_INFO ("stdin is not connected to a terminal");
return FALSE;
}
if (io_watch_id > 0) {
g_source_remove (io_watch_id);
io_watch_id = 0;
}
if (kb_func == NULL && term_settings_saved) {
/* restore terminal settings */
if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &term_settings) == 0)
term_settings_saved = FALSE;
else
g_warning ("could not restore terminal attributes");
setvbuf (stdin, NULL, _IOLBF, 0);
}
if (kb_func != NULL) {
struct termios new_settings;
if (!term_settings_saved) {
if (tcgetattr (STDIN_FILENO, &term_settings) != 0) {
g_warning ("could not save terminal attributes");
return FALSE;
}
term_settings_saved = TRUE;
/* Echo off, canonical mode off, extended input processing off */
new_settings = term_settings;
new_settings.c_lflag &= ~(ECHO | ICANON | IEXTEN);
if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &new_settings) != 0) {
g_warning ("Could not set terminal state");
return FALSE;
}
setvbuf (stdin, NULL, _IONBF, 0);
}
}
ioc = g_io_channel_unix_new (STDIN_FILENO);
/* make non-blocking */
flags = g_io_channel_get_flags (ioc);
g_io_channel_set_flags (ioc, flags | G_IO_FLAG_NONBLOCK, NULL);
io_watch_id = g_io_add_watch_full (ioc, G_PRIORITY_DEFAULT, G_IO_IN,
(GIOFunc) gst_play_kb_io_cb, user_data, NULL);
g_io_channel_unref (ioc);
kb_callback = kb_func;
kb_callback_data = user_data;
return TRUE;
}
#else /* !G_OS_UNIX */
gboolean
gst_play_kb_set_key_handler (GstPlayKbFunc key_func, gpointer user_data)
{
GST_FIXME ("Keyboard handling for this OS needs to be implemented");
return FALSE;
}
#endif /* !G_OS_UNIX */

View file

@ -0,0 +1,35 @@
/* GStreamer command line playback testing utility - keyboard handling helpers
*
* Copyright (C) 2013 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2013 Centricular Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAY_KB_INCLUDED__
#define __GST_PLAY_KB_INCLUDED__
#include <glib.h>
#define GST_PLAY_KB_ARROW_UP "\033[A"
#define GST_PLAY_KB_ARROW_DOWN "\033[B"
#define GST_PLAY_KB_ARROW_RIGHT "\033[C"
#define GST_PLAY_KB_ARROW_LEFT "\033[D"
typedef void (*GstPlayKbFunc) (const gchar * kb_input, gpointer user_data);
gboolean gst_play_kb_set_key_handler (GstPlayKbFunc kb_func, gpointer user_data);
#endif /* __GST_PLAY_KB_INCLUDED__ */

View file

@ -0,0 +1,781 @@
/* GStreamer command line playback testing utility
*
* Copyright (C) 2013-2014 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2013 Collabora Ltd.
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <locale.h>
#include <gst/gst.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "gst-play-kb.h"
#include <gst/play/play.h>
#define VOLUME_STEPS 20
GST_DEBUG_CATEGORY (play_debug);
#define GST_CAT_DEFAULT play_debug
typedef struct
{
gchar **uris;
guint num_uris;
gint cur_idx;
GstPlay *player;
GstPlaySignalAdapter *signal_adapter;
GstState desired_state;
gboolean repeat;
GMainLoop *loop;
} Player;
static gboolean play_next (Player * play);
static gboolean play_prev (Player * play);
static void play_reset (Player * play);
static void play_set_relative_volume (Player * play, gdouble volume_step);
static void
end_of_stream_cb (GstPlaySignalAdapter * adapter, Player * play)
{
gst_print ("\n");
/* and switch to next item in list */
if (!play_next (play)) {
gst_print ("Reached end of play list.\n");
g_main_loop_quit (play->loop);
}
}
static void
error_cb (GstPlaySignalAdapter * adapter, GError * err, Player * play)
{
gst_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]);
/* if looping is enabled, then disable it else will keep looping forever */
play->repeat = FALSE;
/* try next item in list then */
if (!play_next (play)) {
gst_print ("Reached end of play list.\n");
g_main_loop_quit (play->loop);
}
}
static void
position_updated_cb (GstPlaySignalAdapter * adapter, GstClockTime pos,
Player * play)
{
GstClockTime dur = -1;
gchar status[64] = { 0, };
g_object_get (play->player, "duration", &dur, NULL);
memset (status, ' ', sizeof (status) - 1);
if (pos != -1 && dur > 0 && dur != -1) {
gchar dstr[32], pstr[32];
/* FIXME: pretty print in nicer format */
g_snprintf (pstr, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (pos));
pstr[9] = '\0';
g_snprintf (dstr, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (dur));
dstr[9] = '\0';
gst_print ("%s / %s %s\r", pstr, dstr, status);
}
}
static void
state_changed_cb (GstPlaySignalAdapter * adapter, GstPlayState state,
Player * play)
{
gst_print ("State changed: %s\n", gst_play_state_get_name (state));
}
static void
buffering_cb (GstPlaySignalAdapter * adapter, gint percent, Player * play)
{
gst_print ("Buffering: %d\n", percent);
}
static void
print_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
gint i, num;
num = gst_tag_list_get_tag_size (list, tag);
for (i = 0; i < num; ++i) {
const GValue *val;
val = gst_tag_list_get_value_index (list, tag, i);
if (G_VALUE_HOLDS_STRING (val)) {
gst_print (" %s : %s \n", tag, g_value_get_string (val));
} else if (G_VALUE_HOLDS_UINT (val)) {
gst_print (" %s : %u \n", tag, g_value_get_uint (val));
} else if (G_VALUE_HOLDS_DOUBLE (val)) {
gst_print (" %s : %g \n", tag, g_value_get_double (val));
} else if (G_VALUE_HOLDS_BOOLEAN (val)) {
gst_print (" %s : %s \n", tag,
g_value_get_boolean (val) ? "true" : "false");
} else if (GST_VALUE_HOLDS_DATE_TIME (val)) {
GstDateTime *dt = g_value_get_boxed (val);
gchar *dt_str = gst_date_time_to_iso8601_string (dt);
gst_print (" %s : %s \n", tag, dt_str);
g_free (dt_str);
} else {
gst_print (" %s : tag of type '%s' \n", tag, G_VALUE_TYPE_NAME (val));
}
}
}
static void
print_video_info (GstPlayVideoInfo * info)
{
gint fps_n, fps_d;
guint par_n, par_d;
if (info == NULL)
return;
gst_print (" width : %d\n", gst_play_video_info_get_width (info));
gst_print (" height : %d\n", gst_play_video_info_get_height (info));
gst_print (" max_bitrate : %d\n",
gst_play_video_info_get_max_bitrate (info));
gst_print (" bitrate : %d\n", gst_play_video_info_get_bitrate (info));
gst_play_video_info_get_framerate (info, &fps_n, &fps_d);
gst_print (" framerate : %.2f\n", (gdouble) fps_n / fps_d);
gst_play_video_info_get_pixel_aspect_ratio (info, &par_n, &par_d);
gst_print (" pixel-aspect-ratio %u:%u\n", par_n, par_d);
}
static void
print_audio_info (GstPlayAudioInfo * info)
{
if (info == NULL)
return;
gst_print (" sample rate : %d\n",
gst_play_audio_info_get_sample_rate (info));
gst_print (" channels : %d\n", gst_play_audio_info_get_channels (info));
gst_print (" max_bitrate : %d\n",
gst_play_audio_info_get_max_bitrate (info));
gst_print (" bitrate : %d\n", gst_play_audio_info_get_bitrate (info));
gst_print (" language : %s\n", gst_play_audio_info_get_language (info));
}
static void
print_subtitle_info (GstPlaySubtitleInfo * info)
{
if (info == NULL)
return;
gst_print (" language : %s\n", gst_play_subtitle_info_get_language (info));
}
static void
print_all_stream_info (GstPlayMediaInfo * media_info)
{
guint count = 0;
GList *list, *l;
gst_print ("URI : %s\n", gst_play_media_info_get_uri (media_info));
gst_print ("Duration: %" GST_TIME_FORMAT "\n",
GST_TIME_ARGS (gst_play_media_info_get_duration (media_info)));
gst_print ("Global taglist:\n");
if (gst_play_media_info_get_tags (media_info))
gst_tag_list_foreach (gst_play_media_info_get_tags (media_info),
print_one_tag, NULL);
else
gst_print (" (nil) \n");
list = gst_play_media_info_get_stream_list (media_info);
if (!list)
return;
gst_print ("All Stream information\n");
for (l = list; l != NULL; l = l->next) {
GstTagList *tags = NULL;
GstPlayStreamInfo *stream = (GstPlayStreamInfo *) l->data;
gst_print (" Stream # %u \n", count++);
gst_print (" type : %s_%u\n",
gst_play_stream_info_get_stream_type (stream),
gst_play_stream_info_get_index (stream));
tags = gst_play_stream_info_get_tags (stream);
gst_print (" taglist : \n");
if (tags) {
gst_tag_list_foreach (tags, print_one_tag, NULL);
}
if (GST_IS_PLAY_VIDEO_INFO (stream))
print_video_info ((GstPlayVideoInfo *) stream);
else if (GST_IS_PLAY_AUDIO_INFO (stream))
print_audio_info ((GstPlayAudioInfo *) stream);
else
print_subtitle_info ((GstPlaySubtitleInfo *) stream);
}
}
static void
print_all_video_stream (GstPlayMediaInfo * media_info)
{
GList *list, *l;
list = gst_play_media_info_get_video_streams (media_info);
if (!list)
return;
gst_print ("All video streams\n");
for (l = list; l != NULL; l = l->next) {
GstPlayVideoInfo *info = (GstPlayVideoInfo *) l->data;
GstPlayStreamInfo *sinfo = (GstPlayStreamInfo *) info;
gst_print (" %s_%d #\n", gst_play_stream_info_get_stream_type (sinfo),
gst_play_stream_info_get_index (sinfo));
print_video_info (info);
}
}
static void
print_all_subtitle_stream (GstPlayMediaInfo * media_info)
{
GList *list, *l;
list = gst_play_media_info_get_subtitle_streams (media_info);
if (!list)
return;
gst_print ("All subtitle streams:\n");
for (l = list; l != NULL; l = l->next) {
GstPlaySubtitleInfo *info = (GstPlaySubtitleInfo *) l->data;
GstPlayStreamInfo *sinfo = (GstPlayStreamInfo *) info;
gst_print (" %s_%d #\n", gst_play_stream_info_get_stream_type (sinfo),
gst_play_stream_info_get_index (sinfo));
print_subtitle_info (info);
}
}
static void
print_all_audio_stream (GstPlayMediaInfo * media_info)
{
GList *list, *l;
list = gst_play_media_info_get_audio_streams (media_info);
if (!list)
return;
gst_print ("All audio streams: \n");
for (l = list; l != NULL; l = l->next) {
GstPlayAudioInfo *info = (GstPlayAudioInfo *) l->data;
GstPlayStreamInfo *sinfo = (GstPlayStreamInfo *) info;
gst_print (" %s_%d #\n", gst_play_stream_info_get_stream_type (sinfo),
gst_play_stream_info_get_index (sinfo));
print_audio_info (info);
}
}
static void
print_current_tracks (Player * play)
{
GstPlayAudioInfo *audio = NULL;
GstPlayVideoInfo *video = NULL;
GstPlaySubtitleInfo *subtitle = NULL;
gst_print ("Current video track: \n");
video = gst_play_get_current_video_track (play->player);
print_video_info (video);
gst_print ("Current audio track: \n");
audio = gst_play_get_current_audio_track (play->player);
print_audio_info (audio);
gst_print ("Current subtitle track: \n");
subtitle = gst_play_get_current_subtitle_track (play->player);
print_subtitle_info (subtitle);
if (audio)
g_object_unref (audio);
if (video)
g_object_unref (video);
if (subtitle)
g_object_unref (subtitle);
}
static void
print_media_info (GstPlayMediaInfo * media_info)
{
print_all_stream_info (media_info);
gst_print ("\n");
print_all_video_stream (media_info);
gst_print ("\n");
print_all_audio_stream (media_info);
gst_print ("\n");
print_all_subtitle_stream (media_info);
}
static void
media_info_cb (GstPlaySignalAdapter * adapter, GstPlayMediaInfo * info,
Player * play)
{
static int once = 0;
if (!once) {
print_media_info (info);
print_current_tracks (play);
once = 1;
}
}
static Player *
play_new (gchar ** uris, gdouble initial_volume)
{
Player *play;
play = g_new0 (Player, 1);
play->uris = uris;
play->num_uris = g_strv_length (uris);
play->cur_idx = -1;
play->player = gst_play_new (NULL);
play->loop = g_main_loop_new (NULL, FALSE);
play->desired_state = GST_STATE_PLAYING;
play->signal_adapter
= gst_play_signal_adapter_new_with_main_context (play->player,
g_main_loop_get_context (play->loop));
g_signal_connect (play->signal_adapter, "position-updated",
G_CALLBACK (position_updated_cb), play);
g_signal_connect (play->signal_adapter, "state-changed",
G_CALLBACK (state_changed_cb), play);
g_signal_connect (play->signal_adapter, "buffering",
G_CALLBACK (buffering_cb), play);
g_signal_connect (play->signal_adapter, "end-of-stream",
G_CALLBACK (end_of_stream_cb), play);
g_signal_connect (play->signal_adapter, "error", G_CALLBACK (error_cb), play);
g_signal_connect (play->signal_adapter, "media-info-updated",
G_CALLBACK (media_info_cb), play);
play_set_relative_volume (play, initial_volume - 1.0);
return play;
}
static void
play_free (Player * play)
{
play_reset (play);
g_clear_object (&play->signal_adapter);
gst_object_unref (play->player);
g_main_loop_unref (play->loop);
g_strfreev (play->uris);
g_free (play);
}
/* reset for new file/stream */
static void
play_reset (Player * play)
{
}
static void
play_set_relative_volume (Player * play, gdouble volume_step)
{
gdouble volume;
g_object_get (play->player, "volume", &volume, NULL);
volume = round ((volume + volume_step) * VOLUME_STEPS) / VOLUME_STEPS;
volume = CLAMP (volume, 0.0, 10.0);
g_object_set (play->player, "volume", volume, NULL);
gst_print ("Volume: %.0f%% \n", volume * 100);
}
static gchar *
play_uri_get_display_name (Player * play, const gchar * uri)
{
gchar *loc;
if (gst_uri_has_protocol (uri, "file")) {
loc = g_filename_from_uri (uri, NULL, NULL);
} else if (gst_uri_has_protocol (uri, "pushfile")) {
loc = g_filename_from_uri (uri + 4, NULL, NULL);
} else {
loc = g_strdup (uri);
}
/* Maybe additionally use glib's filename to display name function */
return loc;
}
static void
play_uri (Player * play, const gchar * next_uri)
{
gchar *loc;
play_reset (play);
loc = play_uri_get_display_name (play, next_uri);
gst_print ("Now playing %s\n", loc);
g_free (loc);
g_object_set (play->player, "uri", next_uri, NULL);
gst_play_play (play->player);
}
/* returns FALSE if we have reached the end of the playlist */
static gboolean
play_next (Player * play)
{
if ((play->cur_idx + 1) >= play->num_uris) {
if (play->repeat) {
gst_print ("Looping playlist \n");
play->cur_idx = -1;
} else
return FALSE;
}
play_uri (play, play->uris[++play->cur_idx]);
return TRUE;
}
/* returns FALSE if we have reached the beginning of the playlist */
static gboolean
play_prev (Player * play)
{
if (play->cur_idx == 0 || play->num_uris <= 1)
return FALSE;
play_uri (play, play->uris[--play->cur_idx]);
return TRUE;
}
static void
do_play (Player * play)
{
gint i;
/* dump playlist */
for (i = 0; i < play->num_uris; ++i)
GST_INFO ("%4u : %s", i, play->uris[i]);
if (!play_next (play))
return;
g_main_loop_run (play->loop);
}
static void
add_to_playlist (GPtrArray * playlist, const gchar * filename)
{
GDir *dir;
gchar *uri;
if (gst_uri_is_valid (filename)) {
g_ptr_array_add (playlist, g_strdup (filename));
return;
}
if ((dir = g_dir_open (filename, 0, NULL))) {
const gchar *entry;
/* FIXME: sort entries for each directory? */
while ((entry = g_dir_read_name (dir))) {
gchar *path;
path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
add_to_playlist (playlist, path);
g_free (path);
}
g_dir_close (dir);
return;
}
uri = gst_filename_to_uri (filename, NULL);
if (uri != NULL)
g_ptr_array_add (playlist, uri);
else
g_warning ("Could not make URI out of filename '%s'", filename);
}
static void
shuffle_uris (gchar ** uris, guint num)
{
gchar *tmp;
guint i, j;
if (num < 2)
return;
for (i = 0; i < num; i++) {
/* gets equally distributed random number in 0..num-1 [0;num[ */
j = g_random_int_range (0, num);
tmp = uris[j];
uris[j] = uris[i];
uris[i] = tmp;
}
}
static void
restore_terminal (void)
{
gst_play_kb_set_key_handler (NULL, NULL);
}
static void
toggle_paused (Player * play)
{
if (play->desired_state == GST_STATE_PLAYING) {
play->desired_state = GST_STATE_PAUSED;
gst_play_pause (play->player);
} else {
play->desired_state = GST_STATE_PLAYING;
gst_play_play (play->player);
}
}
static void
relative_seek (Player * play, gdouble percent)
{
gint64 dur = -1, pos = -1;
g_return_if_fail (percent >= -1.0 && percent <= 1.0);
g_object_get (play->player, "position", &pos, "duration", &dur, NULL);
if (dur <= 0) {
gst_print ("\nCould not seek.\n");
return;
}
pos = pos + dur * percent;
if (pos < 0)
pos = 0;
gst_play_seek (play->player, pos);
}
static void
keyboard_cb (const gchar * key_input, gpointer user_data)
{
Player *play = (Player *) user_data;
switch (g_ascii_tolower (key_input[0])) {
case 'i':
{
GstPlayMediaInfo *media_info = gst_play_get_media_info (play->player);
if (media_info) {
print_media_info (media_info);
g_object_unref (media_info);
print_current_tracks (play);
}
break;
}
case ' ':
toggle_paused (play);
break;
case 'q':
case 'Q':
g_main_loop_quit (play->loop);
break;
case '>':
if (!play_next (play)) {
gst_print ("\nReached end of play list.\n");
g_main_loop_quit (play->loop);
}
break;
case '<':
play_prev (play);
break;
case 27: /* ESC */
if (key_input[1] == '\0') {
g_main_loop_quit (play->loop);
break;
}
/* fall through */
default:
if (strcmp (key_input, GST_PLAY_KB_ARROW_RIGHT) == 0) {
relative_seek (play, +0.08);
} else if (strcmp (key_input, GST_PLAY_KB_ARROW_LEFT) == 0) {
relative_seek (play, -0.01);
} else if (strcmp (key_input, GST_PLAY_KB_ARROW_UP) == 0) {
play_set_relative_volume (play, +1.0 / VOLUME_STEPS);
} else if (strcmp (key_input, GST_PLAY_KB_ARROW_DOWN) == 0) {
play_set_relative_volume (play, -1.0 / VOLUME_STEPS);
} else {
GST_INFO ("keyboard input:");
for (; *key_input != '\0'; ++key_input)
GST_INFO (" code %3d", *key_input);
}
break;
}
}
int
main (int argc, char **argv)
{
Player *play;
GPtrArray *playlist;
gboolean print_version = FALSE;
gboolean interactive = FALSE; /* FIXME: maybe enable by default? */
gboolean shuffle = FALSE;
gboolean repeat = FALSE;
gdouble volume = 1.0;
gchar **filenames = NULL;
gchar **uris;
guint num, i;
GError *err = NULL;
GOptionContext *ctx;
gchar *playlist_file = NULL;
GOptionEntry options[] = {
{"version", 0, 0, G_OPTION_ARG_NONE, &print_version,
"Print version information and exit", NULL},
{"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle,
"Shuffle playlist", NULL},
{"interactive", 0, 0, G_OPTION_ARG_NONE, &interactive,
"Interactive control via keyboard", NULL},
{"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume,
"Volume", NULL},
{"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file,
"Playlist file containing input media files", NULL},
{"loop", 0, 0, G_OPTION_ARG_NONE, &repeat, "Repeat all", NULL},
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
{NULL}
};
g_set_prgname ("gst-play");
ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ...");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
gst_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
g_clear_error (&err);
g_option_context_free (ctx);
return 1;
}
g_option_context_free (ctx);
GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play");
if (print_version) {
gchar *version_str;
version_str = gst_version_string ();
gst_print ("%s version %s\n", g_get_prgname (), "1.0");
gst_print ("%s\n", version_str);
g_free (version_str);
g_free (playlist_file);
return 0;
}
playlist = g_ptr_array_new ();
if (playlist_file != NULL) {
gchar *playlist_contents = NULL;
gchar **lines = NULL;
if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) {
lines = g_strsplit (playlist_contents, "\n", 0);
num = g_strv_length (lines);
for (i = 0; i < num; i++) {
if (lines[i][0] != '\0') {
GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]);
add_to_playlist (playlist, lines[i]);
}
}
g_strfreev (lines);
g_free (playlist_contents);
} else {
gst_printerr ("Could not read playlist: %s\n", err->message);
g_clear_error (&err);
}
g_free (playlist_file);
playlist_file = NULL;
}
if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) {
gst_printerr ("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ...",
"gst-play");
gst_printerr ("\n\n"),
gst_printerr ("%s\n\n",
"You must provide at least one filename or URI to play.");
/* No input provided. Free array */
g_ptr_array_free (playlist, TRUE);
return 1;
}
/* fill playlist */
if (filenames != NULL && *filenames != NULL) {
num = g_strv_length (filenames);
for (i = 0; i < num; ++i) {
GST_LOG ("command line argument: %s", filenames[i]);
add_to_playlist (playlist, filenames[i]);
}
g_strfreev (filenames);
}
num = playlist->len;
g_ptr_array_add (playlist, NULL);
uris = (gchar **) g_ptr_array_free (playlist, FALSE);
if (shuffle)
shuffle_uris (uris, num);
/* prepare */
play = play_new (uris, volume);
play->repeat = repeat;
if (interactive) {
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
atexit (restore_terminal);
} else {
gst_print ("Interactive keyboard handling in terminal not available.\n");
}
}
/* play */
do_play (play);
/* clean up */
play_free (play);
gst_print ("\n");
gst_deinit ();
return 0;
}

View file

@ -0,0 +1,6 @@
executable('gst-play',
['gst-play.c',
'gst-play-kb.c',
'gst-play-kb.h'],
dependencies : [gst_dep, dependency('gstreamer-play-1.0'), m_dep])

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,176 @@
/* GStreamer
*
* Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "gtk-video-renderer.h"
struct _GstPlayGtkVideoRenderer
{
GObject parent;
GstElement *sink;
GtkWidget *widget;
};
struct _GstPlayGtkVideoRendererClass
{
GObjectClass parent_class;
};
static void
gst_player_gtk_video_renderer_interface_init
(GstPlayVideoRendererInterface * iface);
enum
{
GTK_VIDEO_RENDERER_PROP_0,
GTK_VIDEO_RENDERER_PROP_WIDGET,
GTK_VIDEO_RENDERER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstPlayGtkVideoRenderer,
gst_player_gtk_video_renderer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAY_VIDEO_RENDERER,
gst_player_gtk_video_renderer_interface_init));
static GParamSpec
* gtk_video_renderer_param_specs[GTK_VIDEO_RENDERER_PROP_LAST] = { NULL, };
static void
gst_player_gtk_video_renderer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayGtkVideoRenderer *self = GST_PLAY_GTK_VIDEO_RENDERER (object);
switch (prop_id) {
case GTK_VIDEO_RENDERER_PROP_WIDGET:
g_value_set_object (value, self->widget);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_gtk_video_renderer_finalize (GObject * object)
{
GstPlayGtkVideoRenderer *self = GST_PLAY_GTK_VIDEO_RENDERER (object);
if (self->sink)
gst_object_unref (self->sink);
if (self->widget)
g_object_unref (self->widget);
G_OBJECT_CLASS
(gst_player_gtk_video_renderer_parent_class)->finalize (object);
}
static void
gst_player_gtk_video_renderer_class_init
(GstPlayGtkVideoRendererClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gst_player_gtk_video_renderer_get_property;
gobject_class->finalize = gst_player_gtk_video_renderer_finalize;
gtk_video_renderer_param_specs
[GTK_VIDEO_RENDERER_PROP_WIDGET] =
g_param_spec_object ("widget", "Widget",
"Widget to render the video into", GTK_TYPE_WIDGET,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class,
GTK_VIDEO_RENDERER_PROP_LAST, gtk_video_renderer_param_specs);
}
static void
gst_player_gtk_video_renderer_init (GstPlayGtkVideoRenderer * self)
{
GstElement *gtk_sink = gst_element_factory_make ("gtkglsink", NULL);
if (gtk_sink) {
GstElement *sink = gst_element_factory_make ("glsinkbin", NULL);
g_object_set (sink, "sink", gtk_sink, NULL);
self->sink = sink;
} else {
gtk_sink = gst_element_factory_make ("gtksink", NULL);
self->sink = gst_object_ref_sink (gtk_sink);
}
g_assert (self->sink != NULL);
g_object_get (gtk_sink, "widget", &self->widget, NULL);
}
static GstElement *gst_player_gtk_video_renderer_create_video_sink
(GstPlayVideoRenderer * iface, GstPlay * player)
{
GstPlayGtkVideoRenderer *self = GST_PLAY_GTK_VIDEO_RENDERER (iface);
return gst_object_ref (self->sink);
}
static void
gst_player_gtk_video_renderer_interface_init
(GstPlayVideoRendererInterface * iface)
{
iface->create_video_sink = gst_player_gtk_video_renderer_create_video_sink;
}
/**
* gst_play_gtk_video_renderer_new:
*
* Returns: (transfer full):
*/
GstPlayVideoRenderer *
gst_play_gtk_video_renderer_new (void)
{
GstElementFactory *factory;
factory = gst_element_factory_find ("gtkglsink");
if (!factory)
factory = gst_element_factory_find ("gtksink");
if (!factory)
return NULL;
gst_object_unref (factory);
return g_object_new (GST_TYPE_PLAY_GTK_VIDEO_RENDERER, NULL);
}
/**
* gst_play_gtk_video_renderer_get_widget:
* @self: #GstPlayVideoRenderer instance
*
* Returns: (transfer full): The GtkWidget
*/
GtkWidget *gst_play_gtk_video_renderer_get_widget
(GstPlayGtkVideoRenderer * self)
{
GtkWidget *widget;
g_return_val_if_fail (GST_IS_PLAY_GTK_VIDEO_RENDERER (self), NULL);
g_object_get (self, "widget", &widget, NULL);
return widget;
}

View file

@ -0,0 +1,49 @@
/* GStreamer
*
* Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GTK_VIDEO_RENDERER_H__
#define __GTK_VIDEO_RENDERER_H__
#include <gst/play/play.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef struct _GstPlayGtkVideoRenderer
GstPlayGtkVideoRenderer;
typedef struct _GstPlayGtkVideoRendererClass
GstPlayGtkVideoRendererClass;
#define GST_TYPE_PLAY_GTK_VIDEO_RENDERER (gst_player_gtk_video_renderer_get_type ())
#define GST_IS_PLAY_GTK_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAY_GTK_VIDEO_RENDERER))
#define GST_IS_PLAY_GTK_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAY_GTK_VIDEO_RENDERER))
#define GST_PLAY_GTK_VIDEO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY_GTK_VIDEO_RENDERER, GstPlayGtkVideoRendererClass))
#define GST_PLAY_GTK_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAY_GTK_VIDEO_RENDERER, GstPlayGtkVideoRenderer))
#define GST_PLAY_GTK_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAY_GTK_VIDEO_RENDERER, GstPlayGtkVideoRendererClass))
#define GST_PLAY_GTK_VIDEO_RENDERER_CAST(obj) ((GstPlayGtkVideoRenderer*)(obj))
GType gst_player_gtk_video_renderer_get_type (void);
GstPlayVideoRenderer * gst_play_gtk_video_renderer_new (void);
GtkWidget * gst_play_gtk_video_renderer_get_widget (GstPlayGtkVideoRenderer * self);
G_END_DECLS
#endif /* __GTK_VIDEO_RENDERER_H__ */

View file

@ -0,0 +1,17 @@
gtk_dep = dependency('gtk+-3.0', required: false)
x11_dep = dependency('x11', required: false)
if gtk_dep.found()
gnome = import('gnome')
gtk_play_resources = gnome.compile_resources('gtk-play-resources', 'resources/gresources.xml',
source_dir : './resources',
c_name : 'gtk_play')
executable('gtk-play',
sources: ['gtk-play.c',
gtk_play_resources,
'gtk-video-renderer.h',
'gtk-video-renderer.c'],
dependencies : [glib_dep, gobject_dep, gmodule_dep, gst_dep, gsttag_dep, gstplay_dep, gtk_dep, x11_dep])
endif

View file

@ -0,0 +1,11 @@
<? xml version="1.0" encoding="UTF-8" ?>
<gresources>
<gresource prefix="/ui">
<file>toolbar.ui</file>
<file>media_info_dialog.ui</file>
</gresource>
<gresource prefix="/css">
<file>toolbar.css</file>
</gresource>
</gresources>

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkTreeStore" id="tree">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="media_info_dialog">
<property name="name">media_info_dialog</property>
<property name="can_focus">False</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="media_info_dialog_button">
<property name="label" translatable="yes">Close</property>
<property name="name">media_info_dialog_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="media_info_dialog_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Information about all the streams contains in your media. </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="sw">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_top">5</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">tree</property>
<property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="col">
<property name="sizing">autosize</property>
<property name="title" translatable="yes">col</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,26 @@
* {
background-color: rgba(43,56,54,0.0);
padding: 0px;
}
GtkLabel {
font-size: 10px;
color: #ffffff;
}
#toolbar {
border-radius: 25px;
border: 3px solid #212B2A;
background: rgba(43,56,54,0.6);
}
GtkButton:hover {
border-radius: 45px;
background: rgba(43,56,54,1.0);
border: 1px solid #212B2A;
}
#title_label {
font-size: 12px;
}

View file

@ -0,0 +1,341 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<!-- interface-css-provider-path controls.css -->
<object class="GtkImage" id="forward_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-seek-forward</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="fullscreen_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">25</property>
<property name="icon_name">view-fullscreen</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="next_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-skip-forward</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="pause_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">35</property>
<property name="icon_name">media-playback-pause</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="play_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="pixel_size">35</property>
<property name="icon_name">media-playback-start</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="prev_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-skip-backward</property>
</object>
<object class="GtkImage" id="restore_image">
<property name="name">restore_image</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">25</property>
<property name="icon_name">view-restore</property>
<property name="icon_size">0</property>
</object>
<object class="GtkImage" id="rewind_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">30</property>
<property name="icon_name">media-seek-backward</property>
</object>
<object class="GtkBox" id="toolbar">
<property name="name">toolbar</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">5</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<property name="spacing">9</property>
<child>
<object class="GtkLabel" id="elapshed_time">
<property name="name">elapshed_time</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">00:00</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="seekbar">
<property name="name">seekbar</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="round_digits">1</property>
<property name="draw_value">False</property>
<signal name="value-changed" handler="seekbar_value_changed_cb" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="remain_time">
<property name="name">remain_time</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">00:00</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVolumeButton" id="volume_button">
<property name="name">volume_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="relief">none</property>
<property name="focus_on_click">False</property>
<property name="orientation">vertical</property>
<property name="icons">audio-volume-muted
audio-volume-high
audio-volume-low
audio-volume-medium</property>
<signal name="value-changed" handler="volume_button_value_changed_cb" swapped="no"/>
<child internal-child="plus_button">
<object class="GtkButton" id="volumebutton-plus_button1">
<property name="label" translatable="yes">+</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
</object>
</child>
<child internal-child="minus_button">
<object class="GtkButton" id="volumebutton-minus_button1">
<property name="label" translatable="yes">-</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="fullscreen_button">
<property name="name">fullscreen_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">fullscreen_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="toggled" handler="fullscreen_button_toggled_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">-1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="title_label">
<property name="name">title_label</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="justify">center</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="margin_left">20</property>
<property name="margin_right">20</property>
<property name="margin_bottom">10</property>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="prev_button">
<property name="name">prev_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">prev_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="prev_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="rewind_button">
<property name="name">rewind_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="image">rewind_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="rewind_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="play_pause_button">
<property name="name">play_pause_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">pause_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="play_pause_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="forward_button">
<property name="name">forward_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">forward_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="forward_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="next_button">
<property name="name">next_button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="image">next_image</property>
<property name="relief">none</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<signal name="clicked" handler="next_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="rate_label">
<property name="name">rate_label</property>
<property name="width_request">40</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="justify">right</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View file

@ -0,0 +1,477 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
19A17EFC8D41A75E8D3DB72E /* OnlineMedia.plist in Resources */ = {isa = PBXBuildFile; fileRef = 19A176455D27298FE4041DC3 /* OnlineMedia.plist */; };
AD2B881F198D631B0070367B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B881E198D631B0070367B /* Foundation.framework */; };
AD2B8821198D631B0070367B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B8820198D631B0070367B /* CoreGraphics.framework */; };
AD2B8823198D631B0070367B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2B8822198D631B0070367B /* UIKit.framework */; };
AD2B882B198D631B0070367B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8829198D631B0070367B /* InfoPlist.strings */; };
AD2B882D198D631B0070367B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B882C198D631B0070367B /* main.m */; };
AD2B8831198D631B0070367B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8830198D631B0070367B /* AppDelegate.m */; };
AD2B8833198D631B0070367B /* fonts.conf in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8832198D631B0070367B /* fonts.conf */; };
AD2B8835198D631B0070367B /* Ubuntu-R.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8834198D631B0070367B /* Ubuntu-R.ttf */; };
AD2B8837198D631B0070367B /* gst_ios_init.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8836198D631B0070367B /* gst_ios_init.m */; };
AD2B8858198D637A0070367B /* EaglUIVIew.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8857198D637A0070367B /* EaglUIVIew.m */; };
AD2B885B198D65470070367B /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD2B8859198D65470070367B /* MainStoryboard_iPhone.storyboard */; };
AD2B885C198D65470070367B /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AD2B885A198D65470070367B /* MainStoryboard_iPad.storyboard */; };
AD2B8861198D65780070367B /* LibraryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B885E198D65780070367B /* LibraryViewController.m */; };
AD2B8862198D65780070367B /* VideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD2B8860198D65780070367B /* VideoViewController.m */; };
C911037C220A89150054FB11 /* GStreamer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C911037B220A89150054FB11 /* GStreamer.framework */; };
C9C4AEFD2136C6880048ED8D /* ssl in Resources */ = {isa = PBXBuildFile; fileRef = C9C4AEFB2136C6430048ED8D /* ssl */; };
F4D8C7D71ED455260019B8A3 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F4D8C7D61ED455260019B8A3 /* libiconv.tbd */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
19A176455D27298FE4041DC3 /* OnlineMedia.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = OnlineMedia.plist; sourceTree = "<group>"; };
637F54422097C36400C00B38 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
637F54462097C4D900C00B38 /* libstdc++.6.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.6.tbd"; path = "usr/lib/libstdc++.6.tbd"; sourceTree = SDKROOT; };
AD2B881B198D631B0070367B /* GstPlay.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GstPlay.app; sourceTree = BUILT_PRODUCTS_DIR; };
AD2B881E198D631B0070367B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
AD2B8820198D631B0070367B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
AD2B8822198D631B0070367B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
AD2B8824198D631B0070367B /* GStreamer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GStreamer.framework; path = Library/Frameworks/GStreamer.framework; sourceTree = DEVELOPER_DIR; };
AD2B8828198D631B0070367B /* GstPlay-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GstPlay-Info.plist"; sourceTree = "<group>"; };
AD2B882A198D631B0070367B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
AD2B882C198D631B0070367B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
AD2B882E198D631B0070367B /* GstPlay-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GstPlay-Prefix.pch"; sourceTree = "<group>"; };
AD2B882F198D631B0070367B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
AD2B8830198D631B0070367B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
AD2B8832198D631B0070367B /* fonts.conf */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = fonts.conf; sourceTree = "<group>"; };
AD2B8834198D631B0070367B /* Ubuntu-R.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Ubuntu-R.ttf"; sourceTree = "<group>"; };
AD2B8836198D631B0070367B /* gst_ios_init.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = gst_ios_init.m; sourceTree = "<group>"; };
AD2B8838198D631B0070367B /* gst_ios_init.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gst_ios_init.h; sourceTree = "<group>"; };
AD2B8840198D631B0070367B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
AD2B8856198D637A0070367B /* EaglUIVIew.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaglUIVIew.h; sourceTree = "<group>"; };
AD2B8857198D637A0070367B /* EaglUIVIew.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EaglUIVIew.m; sourceTree = "<group>"; };
AD2B8859198D65470070367B /* MainStoryboard_iPhone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
AD2B885A198D65470070367B /* MainStoryboard_iPad.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
AD2B885D198D65780070367B /* LibraryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LibraryViewController.h; sourceTree = "<group>"; };
AD2B885E198D65780070367B /* LibraryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LibraryViewController.m; sourceTree = "<group>"; };
AD2B885F198D65780070367B /* VideoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoViewController.h; sourceTree = "<group>"; };
AD2B8860198D65780070367B /* VideoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoViewController.m; sourceTree = "<group>"; };
C911037B220A89150054FB11 /* GStreamer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GStreamer.framework; path = ../../../../../../../../../Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework; sourceTree = "<group>"; };
C9C4AEFB2136C6430048ED8D /* ssl */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ssl; sourceTree = "<group>"; };
F4D8C7D61ED455260019B8A3 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
AD2B8818198D631B0070367B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C911037C220A89150054FB11 /* GStreamer.framework in Frameworks */,
F4D8C7D71ED455260019B8A3 /* libiconv.tbd in Frameworks */,
AD2B8821198D631B0070367B /* CoreGraphics.framework in Frameworks */,
AD2B8823198D631B0070367B /* UIKit.framework in Frameworks */,
AD2B881F198D631B0070367B /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
AD2B8812198D631B0070367B = {
isa = PBXGroup;
children = (
AD2B8826198D631B0070367B /* GstPlay */,
AD2B881D198D631B0070367B /* Frameworks */,
AD2B881C198D631B0070367B /* Products */,
);
sourceTree = "<group>";
};
AD2B881C198D631B0070367B /* Products */ = {
isa = PBXGroup;
children = (
AD2B881B198D631B0070367B /* GstPlay.app */,
);
name = Products;
sourceTree = "<group>";
};
AD2B881D198D631B0070367B /* Frameworks */ = {
isa = PBXGroup;
children = (
C911037B220A89150054FB11 /* GStreamer.framework */,
637F54462097C4D900C00B38 /* libstdc++.6.tbd */,
637F54422097C36400C00B38 /* libstdc++.tbd */,
F4D8C7D61ED455260019B8A3 /* libiconv.tbd */,
AD2B881E198D631B0070367B /* Foundation.framework */,
AD2B8820198D631B0070367B /* CoreGraphics.framework */,
AD2B8822198D631B0070367B /* UIKit.framework */,
AD2B8824198D631B0070367B /* GStreamer.framework */,
AD2B8840198D631B0070367B /* XCTest.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
AD2B8826198D631B0070367B /* GstPlay */ = {
isa = PBXGroup;
children = (
AD2B8856198D637A0070367B /* EaglUIVIew.h */,
AD2B8857198D637A0070367B /* EaglUIVIew.m */,
AD2B882F198D631B0070367B /* AppDelegate.h */,
AD2B8830198D631B0070367B /* AppDelegate.m */,
AD2B8859198D65470070367B /* MainStoryboard_iPhone.storyboard */,
AD2B885A198D65470070367B /* MainStoryboard_iPad.storyboard */,
AD2B885D198D65780070367B /* LibraryViewController.h */,
AD2B885E198D65780070367B /* LibraryViewController.m */,
AD2B885F198D65780070367B /* VideoViewController.h */,
AD2B8860198D65780070367B /* VideoViewController.m */,
AD2B8827198D631B0070367B /* Supporting Files */,
19A176455D27298FE4041DC3 /* OnlineMedia.plist */,
);
path = GstPlay;
sourceTree = "<group>";
};
AD2B8827198D631B0070367B /* Supporting Files */ = {
isa = PBXGroup;
children = (
C9C4AEFB2136C6430048ED8D /* ssl */,
AD2B8828198D631B0070367B /* GstPlay-Info.plist */,
AD2B8829198D631B0070367B /* InfoPlist.strings */,
AD2B882C198D631B0070367B /* main.m */,
AD2B882E198D631B0070367B /* GstPlay-Prefix.pch */,
AD2B8832198D631B0070367B /* fonts.conf */,
AD2B8834198D631B0070367B /* Ubuntu-R.ttf */,
AD2B8836198D631B0070367B /* gst_ios_init.m */,
AD2B8838198D631B0070367B /* gst_ios_init.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
AD2B881A198D631B0070367B /* GstPlay */ = {
isa = PBXNativeTarget;
buildConfigurationList = AD2B8850198D631B0070367B /* Build configuration list for PBXNativeTarget "GstPlay" */;
buildPhases = (
AD2B8817198D631B0070367B /* Sources */,
AD2B8818198D631B0070367B /* Frameworks */,
AD2B8819198D631B0070367B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = GstPlay;
productName = GstPlay;
productReference = AD2B881B198D631B0070367B /* GstPlay.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
AD2B8813198D631B0070367B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = "Sebastian Dröge";
};
buildConfigurationList = AD2B8816198D631B0070367B /* Build configuration list for PBXProject "GstPlay" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = AD2B8812198D631B0070367B;
productRefGroup = AD2B881C198D631B0070367B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
AD2B881A198D631B0070367B /* GstPlay */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
AD2B8819198D631B0070367B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AD2B885C198D65470070367B /* MainStoryboard_iPad.storyboard in Resources */,
AD2B885B198D65470070367B /* MainStoryboard_iPhone.storyboard in Resources */,
AD2B8835198D631B0070367B /* Ubuntu-R.ttf in Resources */,
AD2B8833198D631B0070367B /* fonts.conf in Resources */,
AD2B882B198D631B0070367B /* InfoPlist.strings in Resources */,
19A17EFC8D41A75E8D3DB72E /* OnlineMedia.plist in Resources */,
C9C4AEFD2136C6880048ED8D /* ssl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
AD2B8817198D631B0070367B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AD2B8861198D65780070367B /* LibraryViewController.m in Sources */,
AD2B8831198D631B0070367B /* AppDelegate.m in Sources */,
AD2B8862198D65780070367B /* VideoViewController.m in Sources */,
AD2B8858198D637A0070367B /* EaglUIVIew.m in Sources */,
AD2B882D198D631B0070367B /* main.m in Sources */,
AD2B8837198D631B0070367B /* gst_ios_init.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
AD2B8829198D631B0070367B /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
AD2B882A198D631B0070367B /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
AD2B884E198D631B0070367B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_BITCODE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
AD2B884F198D631B0070367B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_BITCODE = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
AD2B8851198D631B0070367B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_CXX_LIBRARY = "libc++";
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(HOME)/Library/Developer/GStreamer/iPhone.sdk",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "GstPlay/GstPlay-Prefix.pch";
HEADER_SEARCH_PATHS = (
"\"$(HOME)/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework/Headers\"",
../lib,
);
INFOPLIST_FILE = "GstPlay/GstPlay-Info.plist";
OTHER_LDFLAGS = (
"-lresolv",
"-lc++",
"-framework",
CoreFoundation,
"-framework",
Foundation,
"-framework",
AVFoundation,
"-framework",
CoreMedia,
"-framework",
CoreVideo,
"-framework",
CoreAudio,
"-framework",
AudioToolbox,
"-weak_framework",
VideoToolbox,
"-framework",
OpenGLES,
"-framework",
AssetsLibrary,
"-framework",
QuartzCore,
"-framework",
AssetsLibrary,
"-framework",
IOSurface,
"-framework",
Metal,
);
PRODUCT_BUNDLE_IDENTIFIER = simon.himmelbauer;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
AD2B8852198D631B0070367B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_CXX_LIBRARY = "libc++";
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(HOME)/Library/Developer/GStreamer/iPhone.sdk",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "GstPlay/GstPlay-Prefix.pch";
HEADER_SEARCH_PATHS = (
"\"$(HOME)/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework/Headers\"",
../lib,
);
INFOPLIST_FILE = "GstPlay/GstPlay-Info.plist";
OTHER_LDFLAGS = (
"-lresolv",
"-lc++",
"-framework",
CoreFoundation,
"-framework",
Foundation,
"-framework",
AVFoundation,
"-framework",
CoreMedia,
"-framework",
CoreVideo,
"-framework",
CoreAudio,
"-framework",
AudioToolbox,
"-weak_framework",
VideoToolbox,
"-framework",
OpenGLES,
"-framework",
AssetsLibrary,
"-framework",
QuartzCore,
"-framework",
AssetsLibrary,
"-framework",
IOSurface,
"-framework",
Metal,
);
PRODUCT_BUNDLE_IDENTIFIER = simon.himmelbauer;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
AD2B8816198D631B0070367B /* Build configuration list for PBXProject "GstPlay" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AD2B884E198D631B0070367B /* Debug */,
AD2B884F198D631B0070367B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AD2B8850198D631B0070367B /* Build configuration list for PBXNativeTarget "GstPlay" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AD2B8851198D631B0070367B /* Debug */,
AD2B8852198D631B0070367B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = AD2B8813198D631B0070367B /* Project object */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:GstPlay.xcodeproj">
</FileRef>
</Workspace>

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B883E198D631B0070367B"
BuildableName = "GstPlayTests.xctest"
BlueprintName = "GstPlayTests"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD2B881A198D631B0070367B"
BuildableName = "GstPlay.app"
BlueprintName = "GstPlay"
ReferencedContainer = "container:GstPlay.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>GstPlay.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>AD2B881A198D631B0070367B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>AD2B883E198D631B0070367B</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,15 @@
//
// AppDelegate.h
// GstPlay
//
// Created by Sebastian Dröge on 02/08/14.
// Copyright (c) 2014 Sebastian Dröge. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View file

@ -0,0 +1,45 @@
//
// AppDelegate.m
// GstPlay
//
// Created by Sebastian Dröge on 02/08/14.
// Copyright (c) 2014 Sebastian Dröge. All rights reserved.
//
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end

View file

@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
@interface EaglUIView : UIView
{
}
@end

View file

@ -0,0 +1,13 @@
#import "EaglUIVIew.h"
#import <QuartzCore/QuartzCore.h>
@implementation EaglUIView
+ (Class) layerClass
{
return [CAEAGLLayer class];
}
@end

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library for demo purposes.</string>
<key>UIMainStoryboardFile</key>
<string>MainStoryboard_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>MainStoryboard_iPad</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View file

@ -0,0 +1,16 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

View file

@ -0,0 +1,12 @@
#import <UIKit/UIKit.h>
@interface LibraryViewController : UITableViewController
{
NSArray *libraryEntries;
NSArray *mediaEntries;
NSArray *onlineEntries;
}
- (IBAction)refresh:(id)sender;
@end

View file

@ -0,0 +1,144 @@
#import "LibraryViewController.h"
#import "VideoViewController.h"
#import <AssetsLibrary/AssetsLibrary.h>
#define ENABLE_IOS_LIBRARY false
@interface LibraryViewController ()
@end
@implementation LibraryViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[super setTitle:@"Library"];
[self refreshMediaItems];
}
- (IBAction)refresh:(id)sender
{
[self refreshMediaItems];
[self.tableView reloadData];
}
static NSString *CellIdentifier = @"CellIdentifier";
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section)
{
case 0: return @"Photo library";
case 1: return @"iTunes file sharing";
default: return @"Online files";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch (section) {
case 0:
return [self->libraryEntries count];
case 1:
return [self->mediaEntries count];
case 2:
return [self->onlineEntries count];
default:
return 0;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure Cell
UILabel *title = (UILabel *)[cell.contentView viewWithTag:10];
UILabel *subtitle = (UILabel *)[cell.contentView viewWithTag:11];
switch (indexPath.section) {
case 0: subtitle.text = [self->libraryEntries objectAtIndex:indexPath.item];
break;
case 1: subtitle.text = [self->mediaEntries objectAtIndex:indexPath.item];
break;
case 2: subtitle.text = [self->onlineEntries objectAtIndex:indexPath.item];
break;
default:
break;
}
NSArray *components = [subtitle.text pathComponents];
title.text = components.lastObject;
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"playVideo"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
VideoViewController *destViewController = segue.destinationViewController;
UITableViewCell *cell = [[self tableView] cellForRowAtIndexPath:indexPath];
UILabel *label = (UILabel *)[cell.contentView viewWithTag:10];
destViewController.title = label.text;
label = (UILabel *)[cell.contentView viewWithTag:11];
destViewController.uri = label.text;
}
}
- (void)refreshMediaItems {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSAllDomainsMask, YES);
#if ENABLE_IOS_LIBRARY
NSString *docsPath = [paths objectAtIndex:0];
NSMutableArray *entries;
/* Entries from the Photo Library */
entries = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
if (group) {
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result) {
[entries addObject:[NSString stringWithFormat:@"%@",[result valueForProperty:ALAssetPropertyAssetURL]]];
*stop = NO;
}
}];
} else {
[self.tableView reloadData];
}
}
failureBlock:^(NSError *error)
{
NSLog(@"ERROR");
}
];
self->libraryEntries = entries;
/* Retrieve entries from iTunes file sharing */
entries = [[NSMutableArray alloc] init];
for (NSString *e in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docsPath error:nil])
{
[entries addObject:[NSString stringWithFormat:@"file://%@/%@", docsPath, e]];
}
self->mediaEntries = entries;
#endif
self->onlineEntries = [NSArray arrayWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"OnlineMedia" withExtension:@"plist"]];
}
@end

View file

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="b7k-ZL-0G1">
<dependencies>
<deployment defaultVersion="1552" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="3gA-ZI-2k3">
<objects>
<navigationController definesPresentationContext="YES" id="b7k-ZL-0G1" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="zhK-zc-ohc">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="VW0-ax-bPv" kind="relationship" relationship="rootViewController" id="bWs-EK-FdN"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Sqh-T0-zkr" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1459" y="-199"/>
</scene>
<!--VideoViewController-->
<scene sceneID="P93-nn-HBJ">
<objects>
<viewController title="Playback" id="z7O-8l-Zeo" userLabel="VideoViewController" customClass="VideoViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="tYu-BR-4pC"/>
<viewControllerLayoutGuide type="bottom" id="gDN-cX-tzD"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="CqS-Gu-I1O">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xWd-bg-0b6" userLabel="VideoContainer">
<rect key="frame" x="0.0" y="0.0" width="768" height="959"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6tN-97-YoQ" userLabel="Video" customClass="EaglUIView">
<rect key="frame" x="224" y="360" width="320" height="240"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="A9A-eK-7QX"/>
<constraint firstAttribute="width" constant="320" id="xcj-6M-2KJ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="6tN-97-YoQ" secondAttribute="centerY" id="UYa-oM-cdf"/>
<constraint firstAttribute="centerX" secondItem="6tN-97-YoQ" secondAttribute="centerX" id="w9H-W0-MfF"/>
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MUi-CE-Ydy">
<rect key="frame" x="0.0" y="980" width="768" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="EwL-Ma-A4v"/>
</constraints>
<items>
<barButtonItem systemItem="play" id="UlF-Ga-2VX">
<connections>
<action selector="play:" destination="z7O-8l-Zeo" id="5xC-uv-9lM"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="pause" id="J3O-8j-Tkt">
<connections>
<action selector="pause:" destination="z7O-8l-Zeo" id="BYM-2X-Tel"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" id="s39-nx-e0L">
<textField key="customView" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="00:00:00 / 00:00:00" borderStyle="roundedRect" textAlignment="center" minimumFontSize="17" id="G8q-Tu-Qx0" userLabel="Time">
<rect key="frame" x="67" y="7" width="140" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</barButtonItem>
<barButtonItem style="plain" id="2n0-TO-8Ss">
<slider key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" id="ufs-E5-87w" userLabel="Slider">
<rect key="frame" x="217" y="11" width="118" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="sliderTouchDown:" destination="z7O-8l-Zeo" eventType="touchDown" id="yV6-eN-VUb"/>
<action selector="sliderTouchUp:" destination="z7O-8l-Zeo" eventType="touchCancel" id="OyS-WZ-sEk"/>
<action selector="sliderTouchUp:" destination="z7O-8l-Zeo" eventType="touchUpOutside" id="Vfz-se-pJg"/>
<action selector="sliderTouchUp:" destination="z7O-8l-Zeo" eventType="touchUpInside" id="kZF-uW-GRo"/>
<action selector="sliderValueChanged:" destination="z7O-8l-Zeo" eventType="valueChanged" id="cwm-pm-BfT"/>
</connections>
</slider>
</barButtonItem>
</items>
</toolbar>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="MUi-CE-Ydy" firstAttribute="trailing" secondItem="CqS-Gu-I1O" secondAttribute="trailing" constant="20" symbolic="YES" id="4vm-hF-9E8"/>
<constraint firstItem="xWd-bg-0b6" firstAttribute="top" secondItem="CqS-Gu-I1O" secondAttribute="top" id="MXr-HK-07f"/>
<constraint firstAttribute="trailing" secondItem="xWd-bg-0b6" secondAttribute="trailing" id="NGT-7D-rHD"/>
<constraint firstItem="MUi-CE-Ydy" firstAttribute="leading" secondItem="CqS-Gu-I1O" secondAttribute="leading" constant="20" symbolic="YES" id="OM9-gE-OVP"/>
<constraint firstItem="xWd-bg-0b6" firstAttribute="leading" secondItem="CqS-Gu-I1O" secondAttribute="leading" id="XO5-WJ-Y3R"/>
<constraint firstItem="MUi-CE-Ydy" firstAttribute="bottom" secondItem="CqS-Gu-I1O" secondAttribute="bottom" constant="20" symbolic="YES" id="w6K-xy-EJe"/>
<constraint firstItem="xWd-bg-0b6" firstAttribute="bottom" secondItem="MUi-CE-Ydy" secondAttribute="top" id="qLn-h6-10Z"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="fGF-kQ-bge"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
<connections>
<outlet property="pause_button" destination="J3O-8j-Tkt" id="Dls-sg-FPm"/>
<outlet property="play_button" destination="UlF-Ga-2VX" id="243-yq-GEe"/>
<outlet property="time_label" destination="G8q-Tu-Qx0" id="jpR-6u-zp0"/>
<outlet property="time_slider" destination="ufs-E5-87w" id="ZUd-jO-4qN"/>
<outlet property="toolbar" destination="MUi-CE-Ydy" id="Lme-0P-4Xq"/>
<outlet property="video_container_view" destination="xWd-bg-0b6" id="7dL-Mp-QGc"/>
<outlet property="video_height_constraint" destination="A9A-eK-7QX" id="rMe-ze-8l5"/>
<outlet property="video_view" destination="6tN-97-YoQ" id="Q0n-dR-hqv"/>
<outlet property="video_width_constraint" destination="xcj-6M-2KJ" id="oTt-9z-KCW"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iRS-GG-bR6" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="439" y="-199"/>
</scene>
<!--LibraryViewController-->
<scene sceneID="bq0-Ch-DBo">
<objects>
<tableViewController title="Library" id="VW0-ax-bPv" userLabel="LibraryViewController" customClass="LibraryViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="hAr-jJ-10J">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CellIdentifier" textLabel="HoX-KW-H9G" detailTextLabel="iD6-8p-XIU" style="IBUITableViewCellStyleSubtitle" id="ujV-TF-eMq">
<rect key="frame" x="0.0" y="119" width="768" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ujV-TF-eMq" id="SAN-nE-evy">
<rect key="frame" x="0.0" y="0.0" width="735" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="10" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="HoX-KW-H9G">
<rect key="frame" x="15" y="2" width="36" height="22"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="11" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iD6-8p-XIU">
<rect key="frame" x="15" y="24" width="50" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="z7O-8l-Zeo" kind="push" identifier="playVideo" id="wKB-w6-zJS"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="VW0-ax-bPv" id="9qF-zP-TH5"/>
<outlet property="delegate" destination="VW0-ax-bPv" id="9Ss-rm-lAe"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="G3n-WN-bmw">
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="Gpf-LU-6E1" userLabel="Refresh">
<connections>
<action selector="refresh:" destination="VW0-ax-bPv" id="nUp-eS-LmM"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7RK-lx-45a" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-478" y="-199"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
</document>

View file

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="z4I-U6-JHy">
<dependencies>
<deployment defaultVersion="1552" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="2zM-sj-9dA">
<objects>
<navigationController definesPresentationContext="YES" id="z4I-U6-JHy" sceneMemberID="viewController">
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="eHD-Ir-W2J">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="bdY-7c-pia" kind="relationship" relationship="rootViewController" id="2oM-BQ-UIl"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7VH-OE-ZqU" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1459" y="-199"/>
</scene>
<!--VideoViewController-->
<scene sceneID="cnz-j4-g9W">
<objects>
<viewController title="Playback" id="iMo-Z9-PrL" userLabel="VideoViewController" customClass="VideoViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="amE-tW-f07"/>
<viewControllerLayoutGuide type="bottom" id="uvN-Av-Fcm"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="zgN-eK-M4Q">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nA3-W2-kn7" userLabel="VideoContainer">
<rect key="frame" x="0.0" y="0.0" width="320" height="481"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WHW-sv-bWc" userLabel="Video" customClass="EaglUIView">
<rect key="frame" x="0.0" y="121" width="320" height="240"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="240" id="5z2-ux-czd"/>
<constraint firstAttribute="width" constant="320" id="76i-Rz-yha"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="WHW-sv-bWc" secondAttribute="centerY" id="3wK-Zr-bQY"/>
<constraint firstAttribute="centerX" secondItem="WHW-sv-bWc" secondAttribute="centerX" id="X5U-dh-PaZ"/>
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="A2w-65-QSF">
<rect key="frame" x="0.0" y="524" width="320" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="apr-w6-VYs"/>
</constraints>
<items>
<barButtonItem style="plain" systemItem="flexibleSpace" id="Ixt-So-LpU"/>
<barButtonItem systemItem="play" id="8Yb-MS-rAF">
<connections>
<action selector="play:" destination="iMo-Z9-PrL" id="9nM-or-ZY7"/>
</connections>
</barButtonItem>
<barButtonItem systemItem="pause" id="nH5-s3-C0i">
<connections>
<action selector="pause:" destination="iMo-Z9-PrL" id="mef-Ij-Agl"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" id="VUJ-y8-aWS">
<textField key="customView" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="00:00:00 / 00:00:00" borderStyle="roundedRect" textAlignment="center" minimumFontSize="17" id="R6T-PH-VPd" userLabel="Time">
<rect key="frame" x="116" y="7" width="139" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="LSl-TA-0qV"/>
</items>
</toolbar>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="4Ns-t9-gs7" userLabel="Slider">
<rect key="frame" x="-2" y="493" width="324" height="31"/>
<connections>
<action selector="sliderTouchDown:" destination="iMo-Z9-PrL" eventType="touchDown" id="jGO-Pw-b5d"/>
<action selector="sliderTouchUp:" destination="iMo-Z9-PrL" eventType="touchCancel" id="L1U-aK-FFn"/>
<action selector="sliderTouchUp:" destination="iMo-Z9-PrL" eventType="touchUpInside" id="jRZ-vw-FQR"/>
<action selector="sliderTouchUp:" destination="iMo-Z9-PrL" eventType="touchUpOutside" id="u1u-UD-WJw"/>
<action selector="sliderValueChanged:" destination="iMo-Z9-PrL" eventType="valueChanged" id="ZOq-XS-0M1"/>
</connections>
</slider>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="A2w-65-QSF" firstAttribute="leading" secondItem="zgN-eK-M4Q" secondAttribute="leading" constant="20" symbolic="YES" id="Aki-Hx-2C9"/>
<constraint firstItem="4Ns-t9-gs7" firstAttribute="trailing" secondItem="zgN-eK-M4Q" secondAttribute="trailing" id="HFi-uV-wdo"/>
<constraint firstAttribute="bottom" secondItem="nA3-W2-kn7" secondAttribute="bottom" constant="87" id="Jdn-RD-NPI"/>
<constraint firstItem="A2w-65-QSF" firstAttribute="trailing" secondItem="zgN-eK-M4Q" secondAttribute="trailing" constant="20" symbolic="YES" id="WWj-l6-D2k"/>
<constraint firstItem="A2w-65-QSF" firstAttribute="bottom" secondItem="zgN-eK-M4Q" secondAttribute="bottom" id="e3s-lP-iPh"/>
<constraint firstAttribute="trailing" secondItem="nA3-W2-kn7" secondAttribute="trailing" id="lOJ-ew-ZyI"/>
<constraint firstItem="nA3-W2-kn7" firstAttribute="top" secondItem="zgN-eK-M4Q" secondAttribute="top" id="lUb-ik-h6u"/>
<constraint firstItem="4Ns-t9-gs7" firstAttribute="leading" secondItem="zgN-eK-M4Q" secondAttribute="leading" id="ma4-AV-cQs"/>
<constraint firstItem="nA3-W2-kn7" firstAttribute="leading" secondItem="zgN-eK-M4Q" secondAttribute="leading" id="p8G-QE-uZ8"/>
<constraint firstAttribute="bottom" secondItem="4Ns-t9-gs7" secondAttribute="bottom" constant="45" id="qfD-gf-vLB"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="xMw-um-vMA"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
<connections>
<outlet property="pause_button" destination="nH5-s3-C0i" id="VWV-EW-jB6"/>
<outlet property="play_button" destination="8Yb-MS-rAF" id="5SI-l2-mAJ"/>
<outlet property="time_label" destination="R6T-PH-VPd" id="bGs-Zr-rv3"/>
<outlet property="time_slider" destination="4Ns-t9-gs7" id="9Ne-1N-clc"/>
<outlet property="video_container_view" destination="nA3-W2-kn7" id="lEY-hP-YHD"/>
<outlet property="video_height_constraint" destination="5z2-ux-czd" id="9R7-fg-G0e"/>
<outlet property="video_view" destination="WHW-sv-bWc" id="c6W-td-a74"/>
<outlet property="video_width_constraint" destination="76i-Rz-yha" id="vSP-Kk-v8g"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="YOs-uD-FMw" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-609" y="-199"/>
</scene>
<!--LibraryViewController-->
<scene sceneID="5eb-Di-aQ1">
<objects>
<tableViewController title="Library" id="bdY-7c-pia" userLabel="LibraryViewController" customClass="LibraryViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="4vG-QM-31k">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="CellIdentifier" textLabel="QLZ-ec-hHM" detailTextLabel="kAu-kE-DrP" style="IBUITableViewCellStyleSubtitle" id="nmS-s6-sIj">
<rect key="frame" x="0.0" y="119" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nmS-s6-sIj" id="P61-er-gaf">
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="10" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QLZ-ec-hHM">
<rect key="frame" x="15" y="2" width="36" height="22"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" tag="11" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="kAu-kE-DrP">
<rect key="frame" x="15" y="24" width="50" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="iMo-Z9-PrL" kind="push" identifier="playVideo" id="jW0-JJ-SqQ"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="bdY-7c-pia" id="yhT-ag-TvP"/>
<outlet property="delegate" destination="bdY-7c-pia" id="usy-2O-hgr"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="3Tj-RI-j7Z">
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="B0E-4z-3fo" userLabel="Refresh">
<connections>
<action selector="refresh:" destination="bdY-7c-pia" id="3oQ-nv-MUd"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pXd-g9-Hdc" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1036" y="-199"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<!-- https://github.com/video-dev/streams HLS streams -->
<string>https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8</string>
<string>https://video-dev.github.io/streams/test_001/stream.m3u8</string>
<!-- Big Buck Bunny -->
<string>http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi</string>
<string>http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov</string>
<string>http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.ogg</string>
<string>http://mirrorblender.top-ix.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.avi</string>
<!--Sintel-->
<string>http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/Sintel_Trailer1.480p.DivX_Plus_HD.mkv</string>
<string>http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/sintel_trailer-480p.mp4</string>
<string>http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/sintel_trailer-480p.ogv</string>
<string>http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4</string>
<!--Tears of Steel-->
<string>http://blender-mirror.kino3d.org/mango/download.blender.org/demo/movies/ToS/tears_of_steel_720p.mkv</string>
<string>http://blender-mirror.kino3d.org/mango/download.blender.org/demo/movies/ToS/tears_of_steel_720p.mov</string>
<string>http://media.xiph.org/mango/tears_of_steel_1080p.webm</string>
<!--Radio stations-->
<string>http://radio.hbr1.com:19800/trance.ogg</string>
<string>http://radio.hbr1.com:19800/tronic.aac</string>
<!--Non-existing entries (to debug error reporting facilities)-->
<string>http://non-existing.org/Non_Existing_Server</string>
<string>http://docs.gstreamer.com/Non_Existing_File</string>
</array>
</plist>

Binary file not shown.

View file

@ -0,0 +1,23 @@
#import <UIKit/UIKit.h>
@interface VideoViewController : UIViewController {
IBOutlet UIBarButtonItem *play_button;
IBOutlet UIBarButtonItem *pause_button;
IBOutlet UIView *video_view;
IBOutlet UIView *video_container_view;
IBOutlet NSLayoutConstraint *video_width_constraint;
IBOutlet NSLayoutConstraint *video_height_constraint;
IBOutlet UIToolbar *toolbar;
IBOutlet UITextField *time_label;
IBOutlet UISlider *time_slider;
}
@property (retain,nonatomic) NSString *uri;
-(IBAction) play:(id)sender;
-(IBAction) pause:(id)sender;
-(IBAction) sliderValueChanged:(id)sender;
-(IBAction) sliderTouchDown:(id)sender;
-(IBAction) sliderTouchUp:(id)sender;
@end

View file

@ -0,0 +1,207 @@
#import "VideoViewController.h"
#import <gst/player/player.h>
#import <UIKit/UIKit.h>
@interface VideoViewController () {
GstPlayer *player;
int media_width; /* Width of the clip */
int media_height; /* height ofthe clip */
Boolean dragging_slider; /* Whether the time slider is being dragged or not */
Boolean is_local_media; /* Whether this clip is stored locally or is being streamed */
Boolean is_playing_desired; /* Whether the user asked to go to PLAYING */
}
@end
@implementation VideoViewController
@synthesize uri;
/*
* Private methods
*/
/* The text widget acts as an slave for the seek bar, so it reflects what the seek bar shows, whether
* it is an actual pipeline position or the position the user is currently dragging to. */
- (void) updateTimeWidget
{
NSInteger position = time_slider.value / 1000;
NSInteger duration = time_slider.maximumValue / 1000;
NSString *position_txt = @" -- ";
NSString *duration_txt = @" -- ";
if (duration > 0) {
NSUInteger hours = duration / (60 * 60);
NSUInteger minutes = (duration / 60) % 60;
NSUInteger seconds = duration % 60;
duration_txt = [NSString stringWithFormat:@"%02u:%02u:%02u", hours, minutes, seconds];
}
if (position > 0) {
NSUInteger hours = position / (60 * 60);
NSUInteger minutes = (position / 60) % 60;
NSUInteger seconds = position % 60;
position_txt = [NSString stringWithFormat:@"%02u:%02u:%02u", hours, minutes, seconds];
}
NSString *text = [NSString stringWithFormat:@"%@ / %@",
position_txt, duration_txt];
time_label.text = text;
}
/*
* Methods from UIViewController
*/
- (void)viewDidLoad
{
[super viewDidLoad];
/* As soon as the GStreamer backend knows the real values, these ones will be replaced */
media_width = 320;
media_height = 240;
player = gst_player_new (gst_player_video_overlay_video_renderer_new ((__bridge gpointer)(video_view)), NULL);
g_object_set (player, "uri", [uri UTF8String], NULL);
gst_debug_set_threshold_for_name("gst-player", GST_LEVEL_TRACE);
g_signal_connect (player, "position-updated", G_CALLBACK (position_updated), (__bridge gpointer) self);
g_signal_connect (player, "duration-changed", G_CALLBACK (duration_changed), (__bridge gpointer) self);
g_signal_connect (player, "video-dimensions-changed", G_CALLBACK (video_dimensions_changed), (__bridge gpointer) self);
is_local_media = [uri hasPrefix:@"file://"];
is_playing_desired = NO;
time_slider.value = 0;
time_slider.minimumValue = 0;
time_slider.maximumValue = 0;
}
- (void)viewDidDisappear:(BOOL)animated
{
if (player)
{
gst_object_unref (player);
}
[UIApplication sharedApplication].idleTimerDisabled = NO;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/* Called when the Play button is pressed */
-(IBAction) play:(id)sender
{
gst_player_play (player);
is_playing_desired = YES;
[UIApplication sharedApplication].idleTimerDisabled = YES;
}
/* Called when the Pause button is pressed */
-(IBAction) pause:(id)sender
{
gst_player_pause(player);
is_playing_desired = NO;
[UIApplication sharedApplication].idleTimerDisabled = NO;
}
/* Called when the time slider position has changed, either because the user dragged it or
* we programmatically changed its position. dragging_slider tells us which one happened */
- (IBAction)sliderValueChanged:(id)sender {
if (!dragging_slider) return;
// If this is a local file, allow scrub seeking, this is, seek as soon as the slider is moved.
if (is_local_media)
gst_player_seek (player, time_slider.value * 1000000);
[self updateTimeWidget];
}
/* Called when the user starts to drag the time slider */
- (IBAction)sliderTouchDown:(id)sender {
gst_player_pause (player);
dragging_slider = YES;
}
/* Called when the user stops dragging the time slider */
- (IBAction)sliderTouchUp:(id)sender {
dragging_slider = NO;
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
// Therefore, perform only the seek when the slider is released.
if (!is_local_media)
gst_player_seek (player, ((long)time_slider.value) * 1000000);
if (is_playing_desired)
gst_player_play (player);
}
/* Called when the size of the main view has changed, so we can
* resize the sub-views in ways not allowed by storyboarding. */
- (void)viewDidLayoutSubviews
{
CGFloat view_width = video_container_view.bounds.size.width;
CGFloat view_height = video_container_view.bounds.size.height;
CGFloat correct_height = view_width * media_height / media_width;
CGFloat correct_width = view_height * media_width / media_height;
if (correct_height < view_height) {
video_height_constraint.constant = correct_height;
video_width_constraint.constant = view_width;
} else {
video_width_constraint.constant = correct_width;
video_height_constraint.constant = view_height;
}
}
static void video_dimensions_changed (GstPlayer * unused, gint width, gint height, VideoViewController * self)
{
dispatch_async(dispatch_get_main_queue(), ^{
if (width > 0 && height > 0) {
[self videoDimensionsChanged:width height:height];
}
});
}
-(void) videoDimensionsChanged:(NSInteger)width height:(NSInteger)height
{
media_width = width;
media_height = height;
[self viewDidLayoutSubviews];
[video_view setNeedsLayout];
[video_view layoutIfNeeded];
}
static void position_updated (GstPlayer * unused, GstClockTime position, VideoViewController *self)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self positionUpdated:(int) (position / 1000000)];
});
}
-(void) positionUpdated:(NSInteger)position
{
/* Ignore messages from the pipeline if the time sliders is being dragged */
if (dragging_slider) return;
time_slider.value = position;
[self updateTimeWidget];
}
static void duration_changed (GstPlayer * unused, GstClockTime duration, VideoViewController *self)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self durationChanged:(int) (duration / 1000000)];
});
}
-(void) durationChanged:(NSInteger)duration
{
time_slider.maximumValue = duration;
[self updateTimeWidget];
}
@end

View file

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

View file

@ -0,0 +1,126 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<!-- Font directory list -->
<dir prefix="xdg"></dir>
<!-- Font cache directory list -->
<cachedir prefix="xdg"></cachedir>
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>monospace</string>
</edit>
</match>
<!--
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans serif</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<config>
<!--
These are the default Unicode chars that are expected to be blank
in fonts. All other blank chars are assumed to be broken and
won't appear in the resulting charsets
-->
<blank>
<int>0x0020</int> <!-- SPACE -->
<int>0x00A0</int> <!-- NO-BREAK SPACE -->
<int>0x00AD</int> <!-- SOFT HYPHEN -->
<int>0x034F</int> <!-- COMBINING GRAPHEME JOINER -->
<int>0x0600</int> <!-- ARABIC NUMBER SIGN -->
<int>0x0601</int> <!-- ARABIC SIGN SANAH -->
<int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER -->
<int>0x0603</int> <!-- ARABIC SIGN SAFHA -->
<int>0x06DD</int> <!-- ARABIC END OF AYAH -->
<int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK -->
<int>0x115F</int> <!-- HANGUL CHOSEONG FILLER -->
<int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
<int>0x1680</int> <!-- OGHAM SPACE MARK -->
<int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ -->
<int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA -->
<int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR -->
<int>0x2000</int> <!-- EN QUAD -->
<int>0x2001</int> <!-- EM QUAD -->
<int>0x2002</int> <!-- EN SPACE -->
<int>0x2003</int> <!-- EM SPACE -->
<int>0x2004</int> <!-- THREE-PER-EM SPACE -->
<int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
<int>0x2006</int> <!-- SIX-PER-EM SPACE -->
<int>0x2007</int> <!-- FIGURE SPACE -->
<int>0x2008</int> <!-- PUNCTUATION SPACE -->
<int>0x2009</int> <!-- THIN SPACE -->
<int>0x200A</int> <!-- HAIR SPACE -->
<int>0x200B</int> <!-- ZERO WIDTH SPACE -->
<int>0x200C</int> <!-- ZERO WIDTH NON-JOINER -->
<int>0x200D</int> <!-- ZERO WIDTH JOINER -->
<int>0x200E</int> <!-- LEFT-TO-RIGHT MARK -->
<int>0x200F</int> <!-- RIGHT-TO-LEFT MARK -->
<int>0x2028</int> <!-- LINE SEPARATOR -->
<int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
<int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
<int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
<int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING -->
<int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
<int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
<int>0x202F</int> <!-- NARROW NO-BREAK SPACE -->
<int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE -->
<int>0x2060</int> <!-- WORD JOINER -->
<int>0x2061</int> <!-- FUNCTION APPLICATION -->
<int>0x2062</int> <!-- INVISIBLE TIMES -->
<int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
<int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
<int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
<int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
<int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
<int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
<int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
<int>0x2800</int> <!-- BRAILLE PATTERN BLANK -->
<int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
<int>0x3164</int> <!-- HANGUL FILLER -->
<int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
<int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER -->
<int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
<int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
<int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
</blank>
<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
<int>30</int>
</rescan>
</config>
</fontconfig>

View file

@ -0,0 +1,39 @@
#ifndef __GST_IOS_INIT_H__
#define __GST_IOS_INIT_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_G_IO_MODULE_DECLARE(name) \
extern void G_PASTE(g_io_, G_PASTE(name, _load)) (gpointer module)
#define GST_G_IO_MODULE_LOAD(name) \
G_PASTE(g_io_, G_PASTE(name, _load)) (NULL)
/* Uncomment each line to enable the plugin categories that your application needs.
* You can also enable individual plugins. See gst_ios_init.c to see their names
*/
#define GST_IOS_PLUGINS_CORE
#define GST_IOS_PLUGINS_CODECS
//#define GST_IOS_PLUGINS_ENCODING
#define GST_IOS_PLUGINS_NET
#define GST_IOS_PLUGINS_PLAYBACK
#define GST_IOS_PLUGINS_VIS
#define GST_IOS_PLUGINS_SYS
#define GST_IOS_PLUGINS_EFFECTS
//#define GST_IOS_PLUGINS_CAPTURE
#define GST_IOS_PLUGINS_CODECS_GPL
#define GST_IOS_PLUGINS_CODECS_RESTRICTED
#define GST_IOS_PLUGINS_NET_RESTRICTED
//#define GST_IOS_PLUGINS_GES
#define GST_IOS_GIO_MODULE_OPENSSL
void gst_ios_init (void);
G_END_DECLS
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#include "gst_ios_init.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
gst_ios_init();
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

View file

View file

@ -0,0 +1,2 @@
subdir('gst-play')
subdir('gtk')

View file

@ -0,0 +1,27 @@
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}
export(INSTALLS)

View file

@ -0,0 +1,39 @@
TEMPLATE = lib
CONFIG += qt plugin
QT += qml quick
CONFIG += c++11
DEFINES += GST_USE_UNSTABLE_API
TARGET = qmlplayerextension
# Additional import path used to resolve QML modules in Qt Creator's code model
# QML_IMPORT_PATH =
HEADERS += qplayerextension.h \
qgstplayer.h \
player.h \
quickrenderer.h \
imagesample.h
SOURCES += qplayerextension.cpp \
qgstplayer.cpp \
player.cpp \
quickrenderer.cpp \
imagesample.cpp
unix:!macx {
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG = \
gstreamer-1.0 \
gstreamer-player-1.0 \
gstreamer-tag-1.0
}
macx {
QMAKE_MAC_SDK = macosx10.9
INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Headers
LIBS += \
-framework AppKit \
-F/Library/Frameworks -framework GStreamer
}

View file

@ -0,0 +1,61 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QPainter>
#include "imagesample.h"
ImageSample::ImageSample()
: QQuickPaintedItem()
, sample_()
{
}
ImageSample::~ImageSample()
{
}
void ImageSample::paint(QPainter *painter)
{
if (sample_.size().isEmpty())
return;
float aspect_ratio = sample_.width() / sample_.height();
int w = height() * aspect_ratio;
int x = (width() - w) / 2;
painter->setViewport(x, 0, w, height());
painter->drawImage(QRectF(0, 0, width(), height()), sample_);
}
const QImage &ImageSample::sample() const
{
return sample_;
}
void ImageSample::setSample(const QImage &sample)
{
sample_ = sample;
update();
}

View file

@ -0,0 +1,46 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef IMAGESAMPLE_H
#define IMAGESAMPLE_H
#include <QObject>
#include <QQuickPaintedItem>
#include <QImage>
#include <QPainter>
#include "player.h"
class ImageSample : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QImage sample READ sample WRITE setSample)
public:
ImageSample();
~ImageSample();
void paint(QPainter *painter);
const QImage &sample() const;
void setSample(const QImage &sample);
private:
QImage sample_;
};
#endif // IMAGESAMPLE_H

View file

@ -0,0 +1,43 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "player.h"
#include "quickrenderer.h"
Player::Player(QObject *parent)
: Player(parent, new QuickRenderer)
{
}
Player::Player(QObject *parent, QuickRenderer *renderer)
: QGstPlayer::Player(parent, renderer)
, renderer_(renderer)
{
renderer_->setParent(this);
}
void Player::setVideoOutput(QVariant output)
{
QQuickItem *item = qvariant_cast<QQuickItem*>(output);
renderer_->setVideoItem(item);
}

View file

@ -0,0 +1,47 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QQuickItem>
#include "qgstplayer.h"
class QuickRenderer;
class Player : public QGstPlayer::Player
{
Q_OBJECT
public:
Player(QObject *parent = 0);
Q_PROPERTY(QVariant videoOutput WRITE setVideoOutput)
private:
Player(QObject *parent, QuickRenderer *renderer);
void setVideoOutput(QVariant output);
QuickRenderer *renderer_;
};
Q_DECLARE_METATYPE(Player*)
#endif // PLAYER_H

View file

@ -0,0 +1,953 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "qgstplayer.h"
#include <QDebug>
#include <QSize>
#include <QMetaObject>
#include <functional>
#include <QThread>
#include <QtAlgorithms>
#include <QImage>
#include <gst/gst.h>
#include <gst/tag/tag.h>
namespace QGstPlayer {
class RegisterMetaTypes
{
public:
RegisterMetaTypes()
{
qRegisterMetaType<Player::State>("State");
}
} _register;
MediaInfo::MediaInfo(Player *player)
: QObject(player)
, uri_()
, title_()
, isSeekable_(false)
, videoStreams_()
, audioStreams_()
, subtitleStreams_()
, sample_()
{
}
QString MediaInfo::uri() const
{
return uri_;
}
QString MediaInfo::title() const
{
return title_;
}
bool MediaInfo::isSeekable() const
{
return isSeekable_;
}
const QList<QObject *> &MediaInfo::videoStreams() const
{
return videoStreams_;
}
const QList<QObject *> &MediaInfo::audioStreams() const
{
return audioStreams_;
}
const QList<QObject*> &MediaInfo::subtitleStreams() const
{
return subtitleStreams_;
}
const QImage &MediaInfo::sample()
{
return sample_;
}
void MediaInfo::update(GstPlayerMediaInfo *info)
{
Q_ASSERT(info != 0);
// FIXME since media-info signal gets emitted
// several times, we just update info iff the
// media uri has changed.
if (uri_ == gst_player_media_info_get_uri(info)) {
return;
}
uri_ = QString(gst_player_media_info_get_uri(info));
title_ = QString::fromLocal8Bit(gst_player_media_info_get_title(info));
// if media has no title, return the file name
if (title_.isEmpty()) {
QUrl url(gst_player_media_info_get_uri(info));
title_ = url.fileName();
}
emit titleChanged();
if (isSeekable_ != gst_player_media_info_is_seekable(info)) {
isSeekable_ = !isSeekable_;
emit seekableChanged();
}
if (!subtitleStreams_.isEmpty()) {
qDeleteAll(subtitleStreams_);
subtitleStreams_.clear();
}
if (!videoStreams_.isEmpty()) {
qDeleteAll(videoStreams_);
videoStreams_.clear();
}
if (!audioStreams_.isEmpty()) {
qDeleteAll(audioStreams_);
audioStreams_.clear();
}
GList *list = gst_player_get_subtitle_streams(info);
g_list_foreach (list, [](gpointer data, gpointer user_data) {
GstPlayerSubtitleInfo *info = static_cast<GstPlayerSubtitleInfo*>(data);
QList<QObject*> *subs = static_cast<QList<QObject*>*>(user_data);
subs->append(new SubtitleInfo(info));
}, &subtitleStreams_);
list = gst_player_get_video_streams(info);
g_list_foreach (list, [](gpointer data, gpointer user_data) {
GstPlayerVideoInfo *info = static_cast<GstPlayerVideoInfo*>(data);
QList<QObject*> *videos = static_cast<QList<QObject*>*>(user_data);
videos->append(new VideoInfo(info));
}, &videoStreams_);
list = gst_player_get_audio_streams(info);
g_list_foreach (list, [](gpointer data, gpointer user_data) {
GstPlayerAudioInfo *info = static_cast<GstPlayerAudioInfo*>(data);
QList<QObject*> *audios = static_cast<QList<QObject*>*>(user_data);
audios->append(new AudioInfo(info));
}, &audioStreams_);
GstSample *sample;
GstMapInfo map_info;
GstBuffer *buffer;
const GstStructure *caps_struct;
GstTagImageType type = GST_TAG_IMAGE_TYPE_UNDEFINED;
/* get image sample buffer from media */
sample = gst_player_media_info_get_image_sample (info);
if (!sample)
return;
buffer = gst_sample_get_buffer (sample);
caps_struct = gst_sample_get_info (sample);
/* if sample is retrieved from preview-image tag then caps struct
* will not be defined. */
if (caps_struct)
gst_structure_get_enum (caps_struct, "image-type",
GST_TYPE_TAG_IMAGE_TYPE, reinterpret_cast<gint*>(&type));
/* FIXME: Should we check more type ?? */
if ((type != GST_TAG_IMAGE_TYPE_FRONT_COVER) &&
(type != GST_TAG_IMAGE_TYPE_UNDEFINED) &&
(type != GST_TAG_IMAGE_TYPE_NONE)) {
gst_print ("unsupport type ... %d \n", type);
return;
}
if (!gst_buffer_map (buffer, &map_info, GST_MAP_READ)) {
gst_print ("failed to map gst buffer \n");
return;
}
sample_ = QImage::fromData(map_info.data, map_info.size);
if (sample_.isNull())
qWarning() << "failed to load media info sample image";
emit sampleChanged();
gst_buffer_unmap (buffer, &map_info);
}
VideoInfo::VideoInfo(GstPlayerVideoInfo *info)
: StreamInfo(reinterpret_cast<GstPlayerStreamInfo*>(info))
, video_(info)
, resolution_(gst_player_video_info_get_width(info), gst_player_video_info_get_height(info))
{
}
QSize VideoInfo::resolution() const
{
return resolution_;
}
AudioInfo::AudioInfo(GstPlayerAudioInfo *info)
: StreamInfo(reinterpret_cast<GstPlayerStreamInfo*>(info))
, audio_(info)
, language_(gst_player_audio_info_get_language(info))
, channels_(gst_player_audio_info_get_channels(info))
, bitRate_(gst_player_audio_info_get_bitrate(info))
, sampleRate_(gst_player_audio_info_get_sample_rate(info))
{
}
const QString &AudioInfo::language() const
{
return language_;
}
int AudioInfo::channels() const
{
return channels_;
}
int AudioInfo::bitRate() const
{
return bitRate_;
}
int AudioInfo::sampleRate() const
{
return sampleRate_;
}
SubtitleInfo::SubtitleInfo(GstPlayerSubtitleInfo *info)
: StreamInfo(reinterpret_cast<GstPlayerStreamInfo*>(info))
, subtitle_(info)
, language_(gst_player_subtitle_info_get_language(info))
{
}
const QString &SubtitleInfo::language() const
{
return language_;
}
int StreamInfo::index() const
{
return index_;
}
StreamInfo::StreamInfo(GstPlayerStreamInfo *info)
: stream_(info)
, index_(gst_player_stream_info_get_index(info))
{
}
bool Player::isVideoAvailable() const
{
GstPlayerVideoInfo *video_info;
video_info = gst_player_get_current_video_track (player_);
if (video_info) {
g_object_unref (video_info);
return true;
}
return false;
}
MediaInfo *Player::mediaInfo() const
{
return mediaInfo_;
}
QVariant Player::currentVideo() const
{
Q_ASSERT(player_ != 0);
GstPlayerVideoInfo *track = gst_player_get_current_video_track(player_);
if (!track)
return QVariant();
return QVariant::fromValue(new VideoInfo(track));
}
QVariant Player::currentAudio() const
{
Q_ASSERT(player_ != 0);
GstPlayerAudioInfo *track = gst_player_get_current_audio_track(player_);
if (!track)
return QVariant();
return QVariant::fromValue(new AudioInfo(track));
}
QVariant Player::currentSubtitle() const
{
Q_ASSERT(player_ != 0);
GstPlayerSubtitleInfo *track = gst_player_get_current_subtitle_track(player_);
if (!track)
return QVariant();
return QVariant::fromValue(new SubtitleInfo(track));
}
void Player::setCurrentVideo(QVariant track)
{
Q_ASSERT(player_ != 0);
VideoInfo* info = track.value<VideoInfo*>();
Q_ASSERT(info);
gst_player_set_video_track(player_, info->index());
}
void Player::setCurrentAudio(QVariant track)
{
Q_ASSERT(player_ != 0);
AudioInfo* info = track.value<AudioInfo*>();
Q_ASSERT(info);
gst_player_set_audio_track(player_, info->index());
}
void Player::setCurrentSubtitle(QVariant track)
{
Q_ASSERT(player_ != 0);
SubtitleInfo* info = track.value<SubtitleInfo*>();
Q_ASSERT(info);
gst_player_set_subtitle_track(player_, info->index());
}
bool Player::isSubtitleEnabled() const
{
return subtitleEnabled_;
}
void Player::setSubtitleEnabled(bool enabled)
{
Q_ASSERT(player_ != 0);
subtitleEnabled_ = enabled;
gst_player_set_subtitle_track_enabled(player_, enabled);
emit subtitleEnabledChanged(enabled);
}
Player::Player(QObject *parent, VideoRenderer *renderer)
: QObject(parent)
, player_()
, state_(STOPPED)
, videoDimensions_(QSize())
, mediaInfo_()
, videoAvailable_(false)
, subtitleEnabled_(false)
, autoPlay_(false)
{
player_ = gst_player_new(renderer ? renderer->renderer() : 0,
gst_player_qt_signal_dispatcher_new(this));
g_object_connect(player_,
"swapped-signal::state-changed", G_CALLBACK (Player::onStateChanged), this,
"swapped-signal::position-updated", G_CALLBACK (Player::onPositionUpdated), this,
"swapped-signal::duration-changed", G_CALLBACK (Player::onDurationChanged), this,
"swapped-signal::buffering", G_CALLBACK (Player::onBufferingChanged), this,
"swapped-signal::video-dimensions-changed", G_CALLBACK (Player::onVideoDimensionsChanged), this,
"swapped-signal::volume-changed", G_CALLBACK (Player::onVolumeChanged), this,
"swapped-signal::mute-changed", G_CALLBACK (Player::onMuteChanged), this,
"swapped-signal::media-info-updated", G_CALLBACK (Player::onMediaInfoUpdated), this,
"swapped-signal::end-of-stream", G_CALLBACK (Player::onEndOfStreamReached), this, NULL);
mediaInfo_ = new MediaInfo(this);
gst_player_set_subtitle_track_enabled(player_, false);
}
Player::~Player()
{
if (player_) {
g_signal_handlers_disconnect_by_data(player_, this);
gst_player_stop(player_);
g_object_unref(player_);
}
}
void
Player::onStateChanged(Player * player, GstPlayerState state)
{
player->state_ = static_cast<Player::State>(state);
emit player->stateChanged(player->state_);
}
void
Player::onPositionUpdated(Player * player, GstClockTime position)
{
emit player->positionUpdated(position);
}
void
Player::onDurationChanged(Player * player, GstClockTime duration)
{
emit player->durationChanged(duration);
}
void
Player::onBufferingChanged(Player * player, int percent)
{
emit player->bufferingChanged(percent);
}
void
Player::onVideoDimensionsChanged(Player * player, int w, int h)
{
QSize res(w,h);
if (res == player->videoDimensions_)
return;
player->videoDimensions_ = res;
player->setResolution(res);
emit player->resolutionChanged(res);
}
void
Player::onVolumeChanged(Player *player)
{
qreal new_val;
new_val = gst_player_get_volume (player->player_);
emit player->volumeChanged(new_val);
}
void
Player::onMuteChanged(Player *player)
{
bool new_val;
new_val = gst_player_get_mute (player->player_);
emit player->mutedChanged(new_val);
}
void
Player::onMediaInfoUpdated(Player *player, GstPlayerMediaInfo *media_info)
{
bool val = player->isVideoAvailable();
if (player->videoAvailable_ != val) {
player->videoAvailable_ = val;
emit player->videoAvailableChanged(val);
}
player->mediaInfo()->update(media_info);
emit player->mediaInfoChanged();
}
void Player::onEndOfStreamReached(Player *player)
{
Q_ASSERT(player != 0);
emit player->endOfStream();
}
void Player::setUri(QUrl url)
{
Q_ASSERT(player_ != 0);
QByteArray uri = url.toEncoded();
gst_player_set_uri(player_, uri.data());
autoPlay_ ? play() : pause();
emit sourceChanged(url);
}
QList<QUrl> Player::playlist() const
{
return playlist_;
}
void Player::setPlaylist(const QList<QUrl> &playlist)
{
if (!playlist_.isEmpty()) {
playlist_.erase(playlist_.begin(), playlist_.end());
}
playlist_ = playlist;
iter_ = playlist_.begin();
setUri(*iter_);
}
void Player::next()
{
if (playlist_.isEmpty())
return;
if (iter_ == playlist_.end())
return;
setUri(*++iter_);
}
void Player::previous()
{
if (playlist_.isEmpty())
return;
if (iter_ == playlist_.begin())
return;
setUri(*--iter_);
}
bool Player::autoPlay() const
{
return autoPlay_;
}
void Player::setAutoPlay(bool auto_play)
{
autoPlay_ = auto_play;
if (autoPlay_) {
connect(this, SIGNAL(endOfStream()), SLOT(next()));
}
}
QUrl Player::source() const
{
Q_ASSERT(player_ != 0);
QString url = QString::fromLocal8Bit(gst_player_get_uri(player_));
return QUrl(url);
}
qint64 Player::duration() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_duration(player_);
}
qint64 Player::position() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_position(player_);
}
qreal Player::volume() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_volume(player_);
}
bool Player::isMuted() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_mute(player_);
}
int Player::buffering() const
{
return 0;
}
QSize Player::resolution() const
{
return videoDimensions_;
}
void Player::setResolution(QSize size)
{
videoDimensions_ = size;
}
Player::State Player::state() const
{
return state_;
}
GstElement *Player::pipeline() const
{
Q_ASSERT(player_ != 0);
return gst_player_get_pipeline(player_);
}
void Player::play()
{
Q_ASSERT(player_ != 0);
gst_player_play(player_);
}
void Player::pause()
{
Q_ASSERT(player_ != 0);
gst_player_pause(player_);
}
void Player::stop()
{
Q_ASSERT(player_ != 0);
gst_player_stop(player_);
}
void Player::seek(qint64 position)
{
Q_ASSERT(player_ != 0);
gst_player_seek(player_, position);
}
void Player::setSource(QUrl const& url)
{
Q_ASSERT(player_ != 0);
// discard playlist
if (!playlist_.isEmpty()) {
playlist_.erase(playlist_.begin(), playlist_.end());
}
setUri(url);
emit sourceChanged(url);
}
void Player::setVolume(qreal val)
{
Q_ASSERT(player_ != 0);
gst_player_set_volume(player_, val);
}
void Player::setMuted(bool val)
{
Q_ASSERT(player_ != 0);
gst_player_set_mute(player_, val);
}
void Player::setPosition(qint64 pos)
{
Q_ASSERT(player_ != 0);
gst_player_seek(player_, pos);
}
GstPlayerVideoRenderer *VideoRenderer::renderer()
{
return static_cast<GstPlayerVideoRenderer*> (gst_object_ref (renderer_));
}
VideoRenderer::VideoRenderer()
{
renderer_ = static_cast<GstPlayerVideoRenderer*>
(g_object_new (GST_TYPE_PLAYER_QT_VIDEO_RENDERER, "renderer", this, NULL));
}
VideoRenderer::~VideoRenderer()
{
if (renderer_) gst_object_unref(renderer_);
}
}
struct _GstPlayerQtVideoRenderer
{
GObject parent;
gpointer renderer;
};
struct _GstPlayerQtVideoRendererClass
{
GObjectClass parent_class;
};
static void
gst_player_qt_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface);
G_DEFINE_TYPE_WITH_CODE (GstPlayerQtVideoRenderer,
gst_player_qt_video_renderer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_VIDEO_RENDERER,
gst_player_qt_video_renderer_interface_init))
enum
{
QT_VIDEO_RENDERER_PROP_0,
QT_VIDEO_RENDERER_PROP_RENDERER,
QT_VIDEO_RENDERER_PROP_LAST
};
static GParamSpec * qt_video_renderer_param_specs
[QT_VIDEO_RENDERER_PROP_LAST] = { NULL, };
static void
gst_player_qt_video_renderer_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstPlayerQtVideoRenderer *self = GST_PLAYER_QT_VIDEO_RENDERER (object);
switch (prop_id) {
case QT_VIDEO_RENDERER_PROP_RENDERER:
self->renderer = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_video_renderer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerQtVideoRenderer *self = GST_PLAYER_QT_VIDEO_RENDERER (object);
switch (prop_id) {
case QT_VIDEO_RENDERER_PROP_RENDERER:
g_value_set_pointer (value, self->renderer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_video_renderer_finalize (GObject * object)
{
G_OBJECT_CLASS
(gst_player_qt_video_renderer_parent_class)->finalize(object);
}
static void
gst_player_qt_video_renderer_class_init
(GstPlayerQtVideoRendererClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property =
gst_player_qt_video_renderer_set_property;
gobject_class->get_property =
gst_player_qt_video_renderer_get_property;
gobject_class->finalize = gst_player_qt_video_renderer_finalize;
qt_video_renderer_param_specs
[QT_VIDEO_RENDERER_PROP_RENDERER] =
g_param_spec_pointer ("renderer", "Qt Renderer", "",
static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (gobject_class,
QT_VIDEO_RENDERER_PROP_LAST,
qt_video_renderer_param_specs);
}
static void
gst_player_qt_video_renderer_init (G_GNUC_UNUSED GstPlayerQtVideoRenderer * self)
{
}
static GstElement *
gst_player_qt_video_renderer_create_video_sink
(GstPlayerVideoRenderer * iface, G_GNUC_UNUSED GstPlayer *player)
{
GstPlayerQtVideoRenderer *self = GST_PLAYER_QT_VIDEO_RENDERER (iface);
g_assert(self->renderer != NULL);
return static_cast<QGstPlayer::VideoRenderer*>(self->renderer)->createVideoSink();
}
static void
gst_player_qt_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface)
{
iface->create_video_sink = gst_player_qt_video_renderer_create_video_sink;
}
struct _GstPlayerQtSignalDispatcher
{
GObject parent;
gpointer player;
};
struct _GstPlayerQtSignalDispatcherClass
{
GObjectClass parent_class;
};
static void
gst_player_qt_signal_dispatcher_interface_init
(GstPlayerSignalDispatcherInterface * iface);
enum
{
QT_SIGNAL_DISPATCHER_PROP_0,
QT_SIGNAL_DISPATCHER_PROP_PLAYER,
QT_SIGNAL_DISPATCHER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstPlayerQtSignalDispatcher,
gst_player_qt_signal_dispatcher, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_SIGNAL_DISPATCHER,
gst_player_qt_signal_dispatcher_interface_init));
static GParamSpec
* qt_signal_dispatcher_param_specs
[QT_SIGNAL_DISPATCHER_PROP_LAST] = { NULL, };
static void
gst_player_qt_signal_dispatcher_finalize (GObject * object)
{
G_OBJECT_CLASS
(gst_player_qt_signal_dispatcher_parent_class)->finalize
(object);
}
static void
gst_player_qt_signal_dispatcher_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstPlayerQtSignalDispatcher *self =
GST_PLAYER_QT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case QT_SIGNAL_DISPATCHER_PROP_PLAYER:
self->player = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_signal_dispatcher_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerQtSignalDispatcher *self =
GST_PLAYER_QT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case QT_SIGNAL_DISPATCHER_PROP_PLAYER:
g_value_set_pointer (value, self->player);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_qt_signal_dispatcher_class_init
(GstPlayerQtSignalDispatcherClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize =
gst_player_qt_signal_dispatcher_finalize;
gobject_class->set_property =
gst_player_qt_signal_dispatcher_set_property;
gobject_class->get_property =
gst_player_qt_signal_dispatcher_get_property;
qt_signal_dispatcher_param_specs
[QT_SIGNAL_DISPATCHER_PROP_PLAYER] =
g_param_spec_pointer ("player", "Player instance", "",
static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (gobject_class,
QT_SIGNAL_DISPATCHER_PROP_LAST,
qt_signal_dispatcher_param_specs);
}
static void
gst_player_qt_signal_dispatcher_init
(G_GNUC_UNUSED GstPlayerQtSignalDispatcher * self)
{
}
static void
gst_player_qt_signal_dispatcher_dispatch (GstPlayerSignalDispatcher
* iface, G_GNUC_UNUSED GstPlayer * player, void (*emitter) (gpointer data), gpointer data,
GDestroyNotify destroy)
{
GstPlayerQtSignalDispatcher *self = GST_PLAYER_QT_SIGNAL_DISPATCHER (iface);
QObject dispatch;
QObject *receiver = static_cast<QObject*>(self->player);
QObject::connect(&dispatch, &QObject::destroyed, receiver, [=]() {
emitter(data);
if (destroy) destroy(data);
}, Qt::QueuedConnection);
}
static void
gst_player_qt_signal_dispatcher_interface_init
(GstPlayerSignalDispatcherInterface * iface)
{
iface->dispatch = gst_player_qt_signal_dispatcher_dispatch;
}
GstPlayerSignalDispatcher *
gst_player_qt_signal_dispatcher_new (gpointer player)
{
return static_cast<GstPlayerSignalDispatcher*>
(g_object_new (GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER,
"player", player, NULL));
}

View file

@ -0,0 +1,312 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef QGSTPLAYER_H
#define QGSTPLAYER_H
#include <QObject>
#include <QUrl>
#include <QSize>
//#include <QtGui/qwindowdefs.h>
#include <QVariant>
#include <QList>
#include <QImage>
#include <gst/player/player.h>
namespace QGstPlayer {
class VideoRenderer;
class MediaInfo;
class StreamInfo;
class VideInfo;
class AudioInfo;
class SubtitleInfo;
class Player : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
Q_PROPERTY(qint64 position READ position NOTIFY positionUpdated)
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
Q_PROPERTY(int buffering READ buffering NOTIFY bufferingChanged)
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(QObject *mediaInfo READ mediaInfo NOTIFY mediaInfoChanged)
Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged)
Q_PROPERTY(QVariant currentVideo READ currentVideo WRITE setCurrentVideo)
Q_PROPERTY(QVariant currentAudio READ currentAudio WRITE setCurrentAudio)
Q_PROPERTY(QVariant currentSubtitle READ currentSubtitle WRITE setCurrentSubtitle)
Q_PROPERTY(bool subtitleEnabled READ isSubtitleEnabled WRITE setSubtitleEnabled
NOTIFY subtitleEnabledChanged)
Q_PROPERTY(bool autoPlay READ autoPlay WRITE setAutoPlay)
Q_PROPERTY(QList<QUrl> playlist READ playlist WRITE setPlaylist)
Q_ENUMS(State)
public:
explicit Player(QObject *parent = 0, VideoRenderer *renderer = 0);
virtual ~Player();
typedef GstPlayerError Error;
enum State {
STOPPED = GST_PLAYER_STATE_STOPPED,
BUFFERING = GST_PLAYER_STATE_BUFFERING,
PAUSED = GST_PLAYER_STATE_PAUSED,
PLAYING = GST_PLAYER_STATE_PLAYING
};
QUrl source() const;
qint64 duration() const;
qint64 position() const;
qreal volume() const;
bool isMuted() const;
int buffering() const;
State state() const;
GstElement *pipeline() const;
QSize resolution() const;
void setResolution(QSize size);
bool isVideoAvailable() const;
MediaInfo *mediaInfo() const;
QVariant currentVideo() const;
QVariant currentAudio() const;
QVariant currentSubtitle() const;
bool isSubtitleEnabled() const;
bool autoPlay() const;
QList<QUrl> playlist() const;
signals:
void stateChanged(State new_state);
void bufferingChanged(int percent);
void endOfStream();
void positionUpdated(qint64 new_position);
void durationChanged(qint64 duration);
void resolutionChanged(QSize resolution);
void volumeChanged(qreal volume);
void mutedChanged(bool muted);
void mediaInfoChanged();
void sourceChanged(QUrl new_url);
void videoAvailableChanged(bool videoAvailable);
void subtitleEnabledChanged(bool enabled);
public slots:
void play();
void pause();
void stop();
void seek(qint64 position);
void setSource(QUrl const& url);
void setVolume(qreal val);
void setMuted(bool val);
void setPosition(qint64 pos);
void setCurrentVideo(QVariant track);
void setCurrentAudio(QVariant track);
void setCurrentSubtitle(QVariant track);
void setSubtitleEnabled(bool enabled);
void setPlaylist(const QList<QUrl> &playlist);
void next();
void previous();
void setAutoPlay(bool auto_play);
private:
Q_DISABLE_COPY(Player)
static void onStateChanged(Player *, GstPlayerState state);
static void onPositionUpdated(Player *, GstClockTime position);
static void onDurationChanged(Player *, GstClockTime duration);
static void onBufferingChanged(Player *, int percent);
static void onVideoDimensionsChanged(Player *, int w, int h);
static void onVolumeChanged(Player *);
static void onMuteChanged(Player *);
static void onMediaInfoUpdated(Player *, GstPlayerMediaInfo *media_info);
static void onEndOfStreamReached(Player *);
void setUri(QUrl url);
GstPlayer *player_;
State state_;
QSize videoDimensions_;
MediaInfo *mediaInfo_;
bool videoAvailable_;
bool subtitleEnabled_;
bool autoPlay_;
QList<QUrl> playlist_;
QList<QUrl>::iterator iter_;
};
class VideoRenderer
{
public:
GstPlayerVideoRenderer *renderer();
virtual GstElement *createVideoSink() = 0;
protected:
VideoRenderer();
virtual ~VideoRenderer();
private:
GstPlayerVideoRenderer *renderer_;
};
class MediaInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(QString uri READ uri NOTIFY uriChanged)
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QList<QObject*> videoStreams READ videoStreams CONSTANT)
Q_PROPERTY(QList<QObject*> audioStreams READ audioStreams CONSTANT)
Q_PROPERTY(QList<QObject*> subtitleStreams READ subtitleStreams CONSTANT)
Q_PROPERTY(QImage sample READ sample NOTIFY sampleChanged)
public:
explicit MediaInfo(Player *player = 0);
QString uri() const;
QString title() const;
bool isSeekable() const;
const QList<QObject*> &videoStreams() const;
const QList<QObject*> &audioStreams() const;
const QList<QObject*> &subtitleStreams() const;
const QImage &sample();
signals:
void uriChanged();
void seekableChanged();
void titleChanged();
void sampleChanged();
public Q_SLOTS:
void update(GstPlayerMediaInfo *info);
private:
QString uri_;
QString title_;
bool isSeekable_;
QList<QObject*> videoStreams_;
QList<QObject*> audioStreams_;
QList<QObject*> subtitleStreams_;
QImage sample_;
};
class StreamInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(int index READ index CONSTANT)
public:
int index() const;
protected:
StreamInfo(GstPlayerStreamInfo* info);
private:
GstPlayerStreamInfo *stream_;
int index_;
};
class VideoInfo : public StreamInfo
{
Q_OBJECT
Q_PROPERTY(QSize resolution READ resolution CONSTANT)
public:
VideoInfo(GstPlayerVideoInfo *info);
QSize resolution() const;
private:
GstPlayerVideoInfo *video_;
QSize resolution_;
};
class AudioInfo : public StreamInfo
{
Q_OBJECT
Q_PROPERTY(QString language READ language CONSTANT)
Q_PROPERTY(int channels READ channels CONSTANT)
Q_PROPERTY(int bitRate READ bitRate CONSTANT)
Q_PROPERTY(int sampleRate READ sampleRate CONSTANT)
public:
AudioInfo(GstPlayerAudioInfo *info);
QString const& language() const;
int channels() const;
int bitRate() const;
int sampleRate() const;
private:
GstPlayerAudioInfo *audio_;
QString language_;
int channels_;
int bitRate_;
int sampleRate_;
};
class SubtitleInfo : public StreamInfo
{
Q_OBJECT
Q_PROPERTY(QString language READ language CONSTANT)
public:
SubtitleInfo(GstPlayerSubtitleInfo *info);
QString const& language() const;
private:
GstPlayerSubtitleInfo *subtitle_;
QString language_;
};
}
Q_DECLARE_METATYPE(QGstPlayer::Player*)
Q_DECLARE_METATYPE(QGstPlayer::Player::State)
Q_DECLARE_METATYPE(QGstPlayer::MediaInfo*)
extern "C" {
typedef struct _GstPlayerQtVideoRenderer
GstPlayerQtVideoRenderer;
typedef struct _GstPlayerQtVideoRendererClass
GstPlayerQtVideoRendererClass;
#define GST_TYPE_PLAYER_QT_VIDEO_RENDERER (gst_player_qt_video_renderer_get_type ())
#define GST_IS_PLAYER_QT_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_QT_VIDEO_RENDERER))
#define GST_IS_PLAYER_QT_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_QT_VIDEO_RENDERER))
#define GST_PLAYER_QT_VIDEO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_QT_VIDEO_RENDERER, GstPlayerQtVideoRendererClass))
#define GST_PLAYER_QT_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_QT_VIDEO_RENDERER, GstPlayerQtVideoRenderer))
#define GST_PLAYER_QT_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_QT_VIDEO_RENDERER, GstPlayerQtVideoRendererClass))
#define GST_PLAYER_QT_VIDEO_RENDERER_CAST(obj) ((GstPlayerQtVideoRenderer*)(obj))
GType gst_player_qt_video_renderer_get_type (void);
typedef struct _GstPlayerQtSignalDispatcher
GstPlayerQtSignalDispatcher;
typedef struct _GstPlayerQtSignalDispatcherClass
GstPlayerQtSignalDispatcherClass;
#define GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER (gst_player_qt_signal_dispatcher_get_type ())
#define GST_IS_PLAYER_QT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER))
#define GST_IS_PLAYER_QT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER, GstPlayerQtSignalDispatcherClass))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER, GstPlayerQtSignalDispatcher))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_QT_SIGNAL_DISPATCHER, GstPlayerQtSignalDispatcherClass))
#define GST_PLAYER_QT_SIGNAL_DISPATCHER_CAST(obj) ((GstPlayerQtSignalDispatcher*)(obj))
GType gst_player_qt_video_renderer_get_type (void);
GstPlayerSignalDispatcher *
gst_player_qt_signal_dispatcher_new (gpointer player);
}
#endif // QGSTPLAYER_H

View file

@ -0,0 +1,2 @@
module extension
plugin qmlplayerextension

View file

@ -0,0 +1,33 @@
/* GStreamer
*
* Copyright (C) 2018 Matthew Waters <matthew@cenricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "qplayerextension.h"
#include "qgstplayer.h"
#include "imagesample.h"
#include <iostream>
void QGstPlayerPlayerExtension::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("extension"));
std::cout << "register uri: " << uri << std::endl;
qmlRegisterType<Player>(uri, 1, 0, "Player");
qmlRegisterType<ImageSample>("extension", 1, 0, "ImageSample");
}

View file

@ -0,0 +1,30 @@
/* GStreamer
*
* Copyright (C) 2018 Matthew Waters <matthew@cenricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QQmlExtensionPlugin>
class QGstPlayerPlayerExtension : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char *uri) override;
};

View file

@ -0,0 +1,56 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "quickrenderer.h"
QuickRenderer::QuickRenderer(QObject *parent)
: QObject(parent)
, QGstPlayer::VideoRenderer()
, sink()
{
}
QuickRenderer::~QuickRenderer()
{
if (sink) gst_object_unref(sink);
}
GstElement *QuickRenderer::createVideoSink()
{
GstElement *qmlglsink = gst_element_factory_make("qmlglsink", NULL);
GstElement *glsinkbin = gst_element_factory_make ("glsinkbin", NULL);
Q_ASSERT(qmlglsink && glsinkbin);
g_object_set (glsinkbin, "sink", qmlglsink, NULL);
sink = static_cast<GstElement*>(gst_object_ref_sink(qmlglsink));
return glsinkbin;
}
void QuickRenderer::setVideoItem(QQuickItem *item)
{
Q_ASSERT(item);
g_object_set(sink, "widget", item, NULL);
}

View file

@ -0,0 +1,42 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef QUICKPLAYER_H
#define QUICKPLAYER_H
#include <QObject>
#include <QQuickItem>
#include "qgstplayer.h"
class QuickRenderer : public QObject, public QGstPlayer::VideoRenderer
{
Q_OBJECT
public:
QuickRenderer(QObject *parent = 0);
~QuickRenderer();
GstElement *createVideoSink();
void setVideoItem(QQuickItem *item);
private:
GstElement *sink;
};
#endif // QUICKPLAYER_H

Binary file not shown.

View file

@ -0,0 +1,10 @@
Font Awesome
URL: http://fontawesome.io
Font License
License: SIL OFL 1.1
URL: http://scripts.sil.org/OFL

View file

@ -0,0 +1,214 @@
var Icon = {
Glass : "\uf000",
Music : "\uf001",
Search : "\uf002",
Envelope : "\uf003",
Heart : "\uf004",
Star : "\uf005",
StarEmpty : "\uf006",
User : "\uf007",
Film : "\uf008",
ThLarge : "\uf009",
Th : "\uf00a",
ThList : "\uf00b",
Ok : "\uf00c",
Remove : "\uf00d",
ZoomIn : "\uf00e",
ZoomOut : "\uf010",
Off : "\uf011",
Signal : "\uf012",
Cog : "\uf013",
Trash : "\uf014",
Home : "\uf015",
File : "\uf016",
Time : "\uf017",
Road : "\uf018",
DownloadAlt : "\uf019",
Download : "\uf01a",
Upload : "\uf01b",
Inbox : "\uf01c",
PlayCircle : "\uf01d",
Repeat : "\uf01e",
Refresh : "\uf021",
ListAlt : "\uf022",
Lock : "\uf023",
Flag : "\uf024",
Headphones : "\uf025",
VolumeOff : "\uf026",
VolumeDown : "\uf027",
VolumeUp : "\uf028",
Qrcode : "\uf029",
Barcode : "\uf02a",
Tag : "\uf02b",
Tags : "\uf02c",
Book : "\uf02d",
Bookmark : "\uf02e",
Print : "\uf02f",
Camera : "\uf030",
Font : "\uf031",
Bold : "\uf032",
Italic : "\uf033",
TextHeight : "\uf034",
TextWidth : "\uf035",
AlignLeft : "\uf036",
AlignCenter : "\uf037",
AlignRight : "\uf038",
AlignJustify : "\uf039",
List : "\uf03a",
IndentLeft : "\uf03b",
IndentRight : "\uf03c",
FacetimeVideo : "\uf03d",
Picture : "\uf03e",
Pencil : "\uf040",
MapMarker : "\uf041",
Adjust : "\uf042",
Tint : "\uf043",
Edit : "\uf044",
Share : "\uf045",
Check : "\uf046",
Move : "\uf047",
StepBackward : "\uf048",
StepForward : "\uf049",
Backward : "\uf04a",
Play : "\uf04b",
Pause : "\uf04c",
Stop : "\uf04d",
Forward : "\uf04e",
FastForward : "\uf050",
StepForward : "\uf051",
Eject : "\uf052",
ChevronLeft : "\uf053",
ChevronRight : "\uf054",
PlusSign : "\uf055",
MinusSign : "\uf056",
RemoveSign : "\uf057",
OkSign : "\uf058",
QuestionSign : "\uf059",
InfoSign : "\uf05a",
Screenshot : "\uf05b",
RemoveCircle : "\uf05c",
OkCircle : "\uf05d",
BanCircle : "\uf05e",
ArrowLeft : "\uf060",
ArrowRight : "\uf061",
ArrowUp : "\uf062",
ArrowDown : "\uf063",
ShareAlt : "\uf064",
ResizeFull : "\uf065",
ResizeSmall : "\uf066",
Plus : "\uf067",
Minus : "\uf068",
Asterish : "\uf069",
ExclamationSign : "\uf06a",
Gift : "\uf06b",
Leave : "\uf06c",
Fire : "\uf06d",
EyeOpen : "\uf06e",
EyeClose : "\uf070",
WarningSign : "\uf071",
Plane : "\uf072",
Calendar : "\uf073",
Random : "\uf074",
Comment : "\uf075",
Magnet : "\uf076",
ChevronUp : "\uf077",
ChevronDown : "\uf078",
Retweet : "\uf079",
ShoppingCart : "\uf07a",
FolderClose : "\uf07b",
FolderOpen : "\uf07c",
ResizeVertical : "\uf07d",
ResizeHorizontal : "\uf07e",
BarChart : "\uf080",
TwitterSign : "\uf081",
FacebookSign : "\uf082",
CameraRetro : "\uf083",
Key : "\uf084",
Cogs : "\uf085",
Comments : "\uf086",
ThumbsUp : "\uf087",
ThumbsDown : "\uf088",
StarHalf : "\uf089",
HeartEmpty : "\uf08a",
Signout : "\uf08b",
LinkedinSign : "\uf08c",
Pushpin : "\uf08d",
ExternalLink : "\uf08e",
Signin : "\uf090",
Trophy : "\uf091",
GithubSign : "\uf092",
UploadAlt : "\uf093",
Lemon : "\uf094",
Phone : "\uf095",
CheckEmpty : "\uf096",
BookmarkEmpty : "\uf097",
PhoneSign : "\uf098",
Twitter : "\uf099",
Facebook : "\uf09a",
Github : "\uf09b",
Unlock : "\uf09c",
CreditCard : "\uf09d",
Rss : "\uf09e",
Hdd : "\uf0a0",
Bullhorn : "\uf0a1",
Bell : "\uf0a2",
Certificate : "\uf0a3",
HandRight : "\uf0a4",
HandLeft : "\uf0a5",
HandUp : "\uf0a6",
HandDown : "\uf0a7",
CircleArrowLeft : "\uf0a8",
CircleArrowRight : "\uf0a9",
CircleArrowUp : "\uf0aa",
CircleArrowDown : "\uf0ab",
Globe : "\uf0ac",
Wrench : "\uf0ad",
Tasks : "\uf0ae",
Filter : "\uf0b0",
Briefcase : "\uf0b1",
Fullscreen : "\uf0b2",
Group : "\uf0c0",
Link : "\uf0c1",
Cloud : "\uf0c2",
Beaker : "\uf0c3",
Cut : "\uf0c4",
Copy : "\uf0c5",
PaperClip : "\uf0c6",
Save : "\uf0c7",
SignBlank : "\uf0c8",
Reorder : "\uf0c9",
ListUl : "\uf0ca",
ListOl : "\uf0cb",
Strikethrough : "\uf0cc",
Underline : "\uf0cd",
Table : "\uf0ce",
Magic : "\uf0d0",
Truck : "\uf0d1",
Pinterest : "\uf0d2",
PinterestSign : "\uf0d3",
GooglePlusSign : "\uf0d4",
GooglePlus : "\uf0d5",
Money : "\uf0d6",
CaretDown : "\uf0d7",
CaretUp : "\uf0d8",
CaretLeft : "\uf0d9",
CaretRight : "\uf0da",
Columns : "\uf0db",
Sort : "\uf0dc",
SortDown : "\uf0dd",
SortUp : "\uf0de",
EnvelopeAlt : "\uf0e0",
Linkedin : "\uf0e1",
Undo : "\uf0e2",
Legal : "\uf0e3",
Dashboard : "\uf0e4",
CommentAlt : "\uf0e5",
CommentsAlt : "\uf0e6",
Bolt : "\uf0e7",
Sitemap : "\uf0e8",
Unbrella : "\uf0e9",
Paste : "\uf0ea",
ClosedCaptions : "\uf20a",
UserMd : "\uf200",
};

View file

@ -0,0 +1,81 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlProperty>
#include <QQuickItem>
#include <QCommandLineParser>
#include <QStringList>
#include <QUrl>
#include <gst/gst.h>
int main(int argc, char *argv[])
{
/* Use QApplication instead of QGuiApplication since the latter is needed
* for widgets like the QFileDialog to work */
QApplication app(argc, argv);
int result;
QCommandLineParser parser;
parser.setApplicationDescription("GstPlayer");
parser.addHelpOption();
parser.addPositionalArgument("urls",
QCoreApplication::translate("main", "URLs to play, optionally."), "[urls...]");
parser.process(app);
QList<QUrl> media_files;
const QStringList args = parser.positionalArguments();
foreach (const QString file, args) {
media_files << QUrl::fromUserInput(file);
}
/* the plugin must be loaded before loading the qml file to register the
* GstGLVideoItem qml item
* FIXME Add a QQmlExtensionPlugin into qmlglsink to register GstGLVideoItem
* with the QML engine, then remove this */
gst_init(NULL,NULL);
GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);
gst_object_unref(sink);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject *rootObject = engine.rootObjects().first();
QObject *player = rootObject->findChild<QObject*>("player");
QObject *videoItem = rootObject->findChild<QObject*>("videoItem");
QVariant v;
v.setValue<QObject*>(videoItem);
QQmlProperty(player, "videoOutput").write(v);
if (!media_files.isEmpty()) {
QVariant v;
v.setValue<QList<QUrl>>(media_files);
QQmlProperty(player, "playlist").write(QVariant (v));
}
result = app.exec();
gst_deinit ();
return result;
}

730
playback/player/qt/main.qml Normal file
View file

@ -0,0 +1,730 @@
/* GStreamer
*
* Copyright (C) 2015 Alexandre Moreno <alexmorenocano@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
import QtQuick 2.4
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.3
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.1
import extension 1.0
import org.freedesktop.gstreamer.GLVideoItem 1.0
import "fontawesome.js" as FontAwesome
ApplicationWindow {
id: window
visible: true
width: 640
height: 480
x: 30
y: 30
color: "black"
// title : player.mediaInfo.title
Player {
id: player
objectName: "player"
volume: 0.5
autoPlay: false
onStateChanged: {
if (state === Player.STOPPED) {
playbutton.state = "play"
}
}
onResolutionChanged: {
if (player.videoAvailable) {
window.width = resolution.width
window.height = resolution.height
}
}
}
GstGLVideoItem {
id: video
objectName: "videoItem"
anchors.centerIn: parent
width: parent.width
height: parent.height
visible: player.videoAvailable
}
ImageSample {
id: sample
anchors.centerIn: parent
sample: player.mediaInfo.sample
width: parent.width
height: parent.height
visible: !player.videoAvailable
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onPositionChanged: {
playbar.opacity = 1.0
hidetimer.start()
}
}
Timer {
id: hidetimer
interval: 5000
onTriggered: {
if (!playbarMouseArea.containsMouse) {
playbar.opacity = 0.0
settings.visible = false
}
stop()
}
}
FileDialog {
id: fileDialog
//nameFilters: [TODO globs from mime types]
onAccepted: player.source = fileUrl
}
Action {
id: fileOpenAction
text: "Open"
onTriggered: fileDialog.open()
}
Item {
anchors.fill: parent
FontLoader {
source: "fonts/fontawesome-webfont.ttf"
}
Rectangle {
id : playbar
color: Qt.rgba(1, 1, 1, 0.7)
border.width: 1
border.color: "white"
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
anchors.horizontalCenter: parent.horizontalCenter
width : grid.width + 20
height: 40//childrenRect.height + 20
radius: 5
focus: true
MouseArea {
id: playbarMouseArea
anchors.fill: parent
hoverEnabled: true
}
Rectangle {
id: settings
width: 150; height: settingsView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
visible: false
ListModel {
id: settingsModel
ListElement {
name: "Video"
}
ListElement {
name: "Audio"
}
ListElement {
name: "Subtitle"
}
}
Component {
id: settingsDelegate
Item {
width: 150; height: 20
Text {
text: model.name
font.pixelSize: 13
anchors.centerIn: parent
}
Text {
font.pixelSize: 13
font.family: "FontAwesome"
text: FontAwesome.Icon.ChevronRight
anchors.right: parent.right
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
switch(name) {
case 'Video':
videos.visible = true
break
case 'Audio':
audios.visible = true
break
case 'Subtitle' :
subtitles.visible = true
break
}
settings.visible = false
}
}
}
}
ListView {
id: settingsView
anchors.fill: parent
model: settingsModel
delegate: settingsDelegate
}
}
Rectangle {
id: videos
width: 150; height: videoView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
property bool selected: ListView.isCurrentItem
visible: false
Component {
id: videoDelegate
Item {
width: 150; height: 20
Text {
text: model.modelData.resolution.width + 'x' + model.modelData.resolution.height
font.pixelSize: 13
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.ListView.view.currentIndex = index
player.currentVideo = model.modelData
}
}
}
}
ListView {
id : videoView
anchors.fill: parent
model: player.mediaInfo.videoStreams
delegate: videoDelegate
highlight: Rectangle {
color: "white"
radius: 5
border.width: 1
border.color: "white"
}
focus: true
clip: true
}
}
Rectangle {
id: audios
width: 150; height: audioView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
property bool selected: ListView.isCurrentItem
visible: false
Component {
id: audioDelegate
Item {
width: 150; height: 20
Text {
text: model.modelData.channels + 'channels'
font.pixelSize: 13
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.ListView.view.currentIndex = index
player.currentAudio = model.modelData
}
}
}
}
ListView {
id : audioView
anchors.fill: parent
model: player.mediaInfo.audioStreams
delegate: audioDelegate
highlight: Rectangle {
color: "white"
radius: 5
border.width: 1
border.color: "white"
}
focus: true
clip: true
}
}
Rectangle {
id: subtitles
width: 150; height: subtitleView.contentHeight
color: Qt.rgba(1, 1, 1, 0.7)
anchors.right: parent.right
anchors.bottom: parent.top
anchors.bottomMargin: 3
border.width: 1
border.color: "white"
radius: 5
property bool selected: ListView.isCurrentItem
visible: false
Component {
id: subtitleDelegate
Item {
width: 150; height: 20
Text {
text: model.modelData.language
font.pixelSize: 13
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.ListView.view.currentIndex = index
player.currentSubtitle = model.modelData
}
}
}
}
ListView {
id : subtitleView
anchors.fill: parent
model: player.mediaInfo.subtitleStreams
delegate: subtitleDelegate
highlight: Rectangle {
color: "white"
radius: 5
border.width: 1
border.color: "white"
}
focus: true
clip: true
}
}
Grid {
id: grid
anchors.horizontalCenter: parent.horizontalCenter
spacing: 7
rows: 1
verticalItemAlignment: Qt.AlignVCenter
Text {
id : openmedia
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.FolderOpen
MouseArea {
anchors.fill: parent
onPressed: fileDialog.open()
}
}
Item {
width: 17
height: 17
Text {
anchors.centerIn: parent
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.StepBackward
}
MouseArea {
anchors.fill: parent
onPressed: player.previous()
}
}
Item {
width: 25
height: 25
Text {
anchors.centerIn: parent
id : playbutton
font.family: "FontAwesome"
state: "play"
states: [
State {
name: "play"
PropertyChanges {
target: playbutton
text: FontAwesome.Icon.PlayCircle
font.pixelSize: 25
}
},
State {
name: "pause"
PropertyChanges {
target: playbutton
text: FontAwesome.Icon.Pause
font.pixelSize: 17
}
}
]
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: {
if (player.state !== Player.PLAYING) {
player.play()
playbutton.state = "pause"
} else {
player.pause()
playbutton.state = "play"
}
}
}
}
Item {
width: 17
height: 17
Text {
anchors.centerIn: parent
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.StepForward
}
MouseArea {
anchors.fill: parent
onPressed: player.next()
}
}
Item {
width: 40
height: 17
Text {
id: timelabel
anchors.centerIn: parent
font.pixelSize: 13
color: "black"
text: {
var current = new Date(Math.floor(slider.value / 1e6));
current.getMinutes() + ":" + ('0'+current.getSeconds()).slice(-2)
}
}
}
Item {
width: 200
height: 38
Text {
anchors.centerIn: parent
width: parent.width
text: player.mediaInfo.title
font.pixelSize: 15
elide: Text.ElideRight
}
}
Item {
width: 40
height: 17
Text {
id: durationlabel
anchors.centerIn: parent
font.pixelSize: 13
color: "black"
text: {
var duration = new Date(Math.floor(player.duration / 1e6));
duration.getMinutes() + ":" + ('0'+duration.getSeconds()).slice(-2)
}
}
}
Text {
id: sub
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.ClosedCaptions
color: player.subtitleEnabled ? "red" : "black"
MouseArea {
anchors.fill: parent
onClicked: {
player.subtitleEnabled = !player.subtitleEnabled
}
}
}
Item {
width: 17
height: 17
Text {
id : volume
anchors.centerIn: parent
font.pixelSize: 17
font.family: "FontAwesome"
text: {
if (volumeslider.value > volumeslider.maximumValue / 2) {
FontAwesome.Icon.VolumeUp
} else if (volumeslider.value === 0) {
FontAwesome.Icon.VolumeOff
} else {
FontAwesome.Icon.VolumeDown
}
}
}
Rectangle {
id : volumebar
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.top
//anchors.bottomMargin:3
color: "lightgray"
width: 17
height: 66
visible: false
radius: 5
Slider {
id: volumeslider
value: player.volume
minimumValue: 0.0
maximumValue: 1.0
stepSize: 0.001
anchors.centerIn: parent
orientation: Qt.Vertical
onPressedChanged: player.volume = value
style: SliderStyle {
groove: Item {
implicitWidth: 47
implicitHeight: 3
anchors.centerIn: parent
Rectangle {
antialiasing: true
height: parent.height
width: parent.width
color: "gray"
opacity: 0.8
radius: 5
Rectangle {
antialiasing: true
height: parent.height
width: parent.width * control.value / control.maximumValue
color: "red"
radius: 5
}
}
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 1
implicitWidth: 11
implicitHeight: 11
radius: 90
}
}
}
}
MouseArea {
anchors.fill: parent
onPressed: {
volumebar.visible = !volumebar.visible
}
}
MouseArea {
anchors.fill: volumebar
hoverEnabled: true
propagateComposedEvents: true
onClicked: mouse.accepted = false;
onPressed: mouse.accepted = false;
onReleased: mouse.accepted = false;
onDoubleClicked: mouse.accepted = false;
onPositionChanged: mouse.accepted = false;
onPressAndHold: mouse.accepted = false;
onExited: {
volumebar.visible = false
}
}
}
Text {
id: cog
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.Cog
MouseArea {
anchors.fill: parent
onClicked: {
settings.visible = !settings.visible
videos.visible = false
audios.visible = false
subtitles.visible = false
}
}
}
Text {
id : fullscreen
font.pixelSize: 17
font.family: "FontAwesome"
text: FontAwesome.Icon.ResizeFull
MouseArea {
anchors.fill: parent
onClicked: {
if (window.visibility === Window.FullScreen) {
window.showNormal()
fullscreen.text = FontAwesome.Icon.ResizeFull
} else {
window.showFullScreen()
fullscreen.text = FontAwesome.Icon.ResizeSmall
}
}
}
}
}
Item {
width: playbar.width
height: 5
anchors.bottom: playbar.bottom
Slider {
id: slider
maximumValue: player.duration
value: player.position
onPressedChanged: player.seek(value)
onValueChanged: {
if (pressed)
player.seek(value)
}
enabled: player.mediaInfo.seekable
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
updateValueWhileDragging: true
MouseArea {
id: sliderMouseArea
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true
onClicked: mouse.accepted = false;
onPressed: mouse.accepted = false;
onReleased: mouse.accepted = false;
onDoubleClicked: mouse.accepted = false;
onPositionChanged: mouse.accepted = false;
onPressAndHold: mouse.accepted = false;
}
style: SliderStyle {
groove: Item {
implicitWidth: playbar.width
implicitHeight: 5
Rectangle {
height: parent.height
width: parent.width
anchors.verticalCenter: parent.verticalCenter
color: "gray"
opacity: 0.8
Rectangle {
antialiasing: true
color: "red"
height: parent.height
width: parent.width * control.value / control.maximumValue
}
Rectangle {
antialiasing: true
color: "yellow"
height: parent.height
width: parent.width * player.buffering / 100
}
}
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
implicitWidth: 4
implicitHeight: 5
}
}
}
}
}
}
}

View file

@ -0,0 +1,40 @@
TEMPLATE = app
QT += qml quick widgets
CONFIG += c++11
DEFINES += GST_USE_UNSTABLE_API
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
# not tested (yet)
unix:!macx {
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG = \
gstreamer-1.0 \
gstreamer-player-1.0 \
gstreamer-tag-1.0
}
macx {
QMAKE_MAC_SDK = macosx10.9
INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Headers
LIBS += \
-framework AppKit \
-F/Library/Frameworks -framework GStreamer
}
HEADERS +=
SOURCES += main.cpp
DISTFILES +=

View file

@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>fontawesome.js</file>
</qresource>
<qresource prefix="/fonts">
<file>fontawesome-webfont.ttf</file>
</qresource>
</RCC>

View file

@ -0,0 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = extension play
play.depends = extension
play.file = play.pro

10
vulkan/android/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
.cxx/
.externalNativeBuild/
.gradle/
.idea/
assets/
build/
gst-build-*/
local.properties
src/org/freedesktop/gstreamer/GStreamer.java
*.iml

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.freedesktop.gstreamer.vulkan.vulkan_1">
<uses-feature android:name="android.hardware.vulkan.version"
android:version="0x400003"
android:required="true"/>
<application android:label="@string/app_name">
<activity android:name="org.freedesktop.gstreamer.vulkan.Vulkan1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View file

@ -0,0 +1,89 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "org.freedesktop.gstreamer.vulkan.vulkan_1"
minSdkVersion 24
targetSdkVersion 24
versionCode 1
versionName "1.0"
archivesBaseName = "$applicationId-v$versionCode"
externalNativeBuild {
ndkBuild {
def gstRoot
if (project.hasProperty('gstAndroidRoot'))
gstRoot = project.gstAndroidRoot
else
gstRoot = System.env.GSTREAMER_ROOT_ANDROID
if (gstRoot == null)
throw new GradleException('GSTREAMER_ROOT_ANDROID must be set, or "gstAndroidRoot" must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries')
arguments "NDK_APPLICATION_MK=jni/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src", "GSTREAMER_ROOT_ANDROID=$gstRoot", "GSTREAMER_ASSETS_DIR=src/assets"
targets "vulkan-1"
// All archs except MIPS and MIPS64 are supported
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
}
afterEvaluate {
if (project.hasProperty('compileDebugJavaWithJavac'))
project.compileDebugJavaWithJavac.dependsOn 'externalNativeBuildDebug'
if (project.hasProperty('compileReleaseJavaWithJavac'))
project.compileReleaseJavaWithJavac.dependsOn 'externalNativeBuildRelease'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.1.1'
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
repositories {
jcenter()
google()
}

View file

@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# gstAndroidRoot can be set to point to the unpacked GStreamer android top-level directory
# containing each architecture in subdirectories, or else set the GSTREAMER_ROOT_ANDROID
# environment variable to that location
# gstAndroidRoot=/path/to/gstreamer/android

Binary file not shown.

View file

@ -0,0 +1,6 @@
#Sat Apr 21 19:58:19 WEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

160
vulkan/android/gradlew vendored Executable file
View file

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
vulkan/android/gradlew.bat vendored Normal file
View file

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1,34 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := vulkan-1
LOCAL_SRC_FILES := vulkan-1.c dummy.cpp
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_SHARED_LIBRARY)
ifndef GSTREAMER_ROOT_ANDROID
$(error GSTREAMER_ROOT_ANDROID is not defined!)
endif
ifeq ($(TARGET_ARCH_ABI),armeabi)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/arm
else ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/armv7
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/arm64
else ifeq ($(TARGET_ARCH_ABI),x86)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/x86
else ifeq ($(TARGET_ARCH_ABI),x86_64)
GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/x86_64
else
$(error Target arch ABI not supported: $(TARGET_ARCH_ABI))
endif
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_SYS) $(GSTREAMER_PLUGINS_EFFECTS) vulkan androidmedia
GSTREAMER_EXTRA_DEPS := gstreamer-video-1.0 gobject-2.0
GSTREAMER_EXTRA_LIBS := -liconv
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer-1.0.mk

View file

@ -0,0 +1,2 @@
APP_ABI = armeabi armeabi-v7a arm64-v8a x86 x86_64
APP_STL = c++_shared

View file

View file

@ -0,0 +1,403 @@
#include <string.h>
#include <stdint.h>
#include <jni.h>
#include <android/log.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <pthread.h>
GST_DEBUG_CATEGORY_STATIC (debug_category);
#define GST_CAT_DEFAULT debug_category
/*
* These macros provide a way to store the native pointer to CustomData, which might be 32 or 64 bits, into
* a jlong, which is always 64 bits, without warnings.
*/
#if GLIB_SIZEOF_VOID_P == 8
# define GET_CUSTOM_DATA(env, thiz, fieldID) (CustomData *)(*env)->GetLongField (env, thiz, fieldID)
# define SET_CUSTOM_DATA(env, thiz, fieldID, data) (*env)->SetLongField (env, thiz, fieldID, (jlong)data)
#else
# define GET_CUSTOM_DATA(env, thiz, fieldID) (CustomData *)(jint)(*env)->GetLongField (env, thiz, fieldID)
# define SET_CUSTOM_DATA(env, thiz, fieldID, data) (*env)->SetLongField (env, thiz, fieldID, (jlong)(jint)data)
#endif
/* Structure to contain all our information, so we can pass it to callbacks */
typedef struct _CustomData
{
jobject app; /* Application instance, used to call its methods. A global reference is kept. */
GstElement *pipeline; /* The running pipeline */
GMainContext *context; /* GLib context used to run the main loop */
GMainLoop *main_loop; /* GLib main loop */
gboolean initialized; /* To avoid informing the UI multiple times about the initialization */
GstElement *video_sink; /* The video sink element which receives XOverlay commands */
ANativeWindow *native_window; /* The Android native window where video will be rendered */
} CustomData;
/* These global variables cache values which are not changing during execution */
static pthread_t gst_app_thread;
static pthread_key_t current_jni_env;
static JavaVM *java_vm;
static jfieldID custom_data_field_id;
static jmethodID set_message_method_id;
static jmethodID on_gstreamer_initialized_method_id;
/*
* Private methods
*/
/* Register this thread with the VM */
static JNIEnv *
attach_current_thread (void)
{
JNIEnv *env;
JavaVMAttachArgs args;
GST_DEBUG ("Attaching thread %p", g_thread_self ());
args.version = JNI_VERSION_1_4;
args.name = NULL;
args.group = NULL;
if ((*java_vm)->AttachCurrentThread (java_vm, &env, &args) < 0) {
GST_ERROR ("Failed to attach current thread");
return NULL;
}
return env;
}
/* Unregister this thread from the VM */
static void
detach_current_thread (void *env)
{
GST_DEBUG ("Detaching thread %p", g_thread_self ());
(*java_vm)->DetachCurrentThread (java_vm);
}
/* Retrieve the JNI environment for this thread */
static JNIEnv *
get_jni_env (void)
{
JNIEnv *env;
if ((env = pthread_getspecific (current_jni_env)) == NULL) {
env = attach_current_thread ();
pthread_setspecific (current_jni_env, env);
}
return env;
}
/* Change the content of the UI's TextView */
static void
set_ui_message (const gchar * message, CustomData * data)
{
JNIEnv *env = get_jni_env ();
GST_DEBUG ("Setting message to: %s", message);
jstring jmessage = (*env)->NewStringUTF (env, message);
(*env)->CallVoidMethod (env, data->app, set_message_method_id, jmessage);
if ((*env)->ExceptionCheck (env)) {
GST_ERROR ("Failed to call Java method");
(*env)->ExceptionClear (env);
}
(*env)->DeleteLocalRef (env, jmessage);
}
/* Retrieve errors from the bus and show them on the UI */
static void
error_cb (GstBus * bus, GstMessage * msg, CustomData * data)
{
GError *err;
gchar *debug_info;
gchar *message_string;
gst_message_parse_error (msg, &err, &debug_info);
message_string =
g_strdup_printf ("Error received from element %s: %s",
GST_OBJECT_NAME (msg->src), err->message);
g_clear_error (&err);
g_free (debug_info);
set_ui_message (message_string, data);
g_free (message_string);
gst_element_set_state (data->pipeline, GST_STATE_NULL);
}
/* Notify UI about pipeline state changes */
static void
state_changed_cb (GstBus * bus, GstMessage * msg, CustomData * data)
{
GstState old_state, new_state, pending_state;
gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);
/* Only pay attention to messages coming from the pipeline, not its children */
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->pipeline)) {
gchar *message = g_strdup_printf ("State changed to %s",
gst_element_state_get_name (new_state));
set_ui_message (message, data);
g_free (message);
}
}
/* Check if all conditions are met to report GStreamer as initialized.
* These conditions will change depending on the application */
static void
check_initialization_complete (CustomData * data)
{
JNIEnv *env = get_jni_env ();
if (!data->initialized && data->native_window && data->main_loop) {
GST_DEBUG
("Initialization complete, notifying application. native_window:%p main_loop:%p",
data->native_window, data->main_loop);
/* The main loop is running and we received a native window, inform the sink about it */
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (data->video_sink),
(guintptr) data->native_window);
(*env)->CallVoidMethod (env, data->app, on_gstreamer_initialized_method_id);
if ((*env)->ExceptionCheck (env)) {
GST_ERROR ("Failed to call Java method");
(*env)->ExceptionClear (env);
}
data->initialized = TRUE;
}
}
/* Main method for the native code. This is executed on its own thread. */
static void *
app_function (void *userdata)
{
JavaVMAttachArgs args;
GstBus *bus;
CustomData *data = (CustomData *) userdata;
GSource *bus_source;
GError *error = NULL;
GST_DEBUG ("Creating pipeline in CustomData at %p", data);
/* Create our own GLib Main Context and make it the default one */
data->context = g_main_context_new ();
g_main_context_push_thread_default (data->context);
/* Build pipeline */
data->pipeline =
gst_parse_launch
("videotestsrc ! warptv ! videoconvert ! vulkanupload ! vulkancolorconvert ! vulkansink",
&error);
if (error) {
gchar *message =
g_strdup_printf ("Unable to build pipeline: %s", error->message);
g_clear_error (&error);
set_ui_message (message, data);
g_free (message);
return NULL;
}
/* Set the pipeline to READY, so it can already accept a window handle, if we have one */
gst_element_set_state (data->pipeline, GST_STATE_READY);
data->video_sink =
gst_bin_get_by_interface (GST_BIN (data->pipeline),
GST_TYPE_VIDEO_OVERLAY);
if (!data->video_sink) {
GST_ERROR ("Could not retrieve video sink");
return NULL;
}
/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
bus = gst_element_get_bus (data->pipeline);
bus_source = gst_bus_create_watch (bus);
g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func,
NULL, NULL);
g_source_attach (bus_source, data->context);
g_source_unref (bus_source);
g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb,
data);
g_signal_connect (G_OBJECT (bus), "message::state-changed",
(GCallback) state_changed_cb, data);
gst_object_unref (bus);
/* Create a GLib Main Loop and set it to run */
GST_DEBUG ("Entering main loop... (CustomData:%p)", data);
data->main_loop = g_main_loop_new (data->context, FALSE);
check_initialization_complete (data);
g_main_loop_run (data->main_loop);
GST_DEBUG ("Exited main loop");
g_main_loop_unref (data->main_loop);
data->main_loop = NULL;
/* Free resources */
g_main_context_pop_thread_default (data->context);
g_main_context_unref (data->context);
gst_element_set_state (data->pipeline, GST_STATE_NULL);
gst_object_unref (data->video_sink);
gst_object_unref (data->pipeline);
return NULL;
}
/*
* Java Bindings
*/
/* Instruct the native code to create its internal data structure, pipeline and thread */
static void
gst_native_init (JNIEnv * env, jobject thiz)
{
CustomData *data = g_new0 (CustomData, 1);
SET_CUSTOM_DATA (env, thiz, custom_data_field_id, data);
GST_DEBUG_CATEGORY_INIT (debug_category, "vulkan-1", 0, "Android vulkan 1");
gst_debug_set_threshold_for_name ("vulkan-1", GST_LEVEL_DEBUG);
gst_debug_set_threshold_from_string ("3,*vulkan*:7", FALSE);
GST_DEBUG ("Created CustomData at %p", data);
data->app = (*env)->NewGlobalRef (env, thiz);
GST_DEBUG ("Created GlobalRef for app object at %p", data->app);
pthread_create (&gst_app_thread, NULL, &app_function, data);
}
/* Quit the main loop, remove the native thread and free resources */
static void
gst_native_finalize (JNIEnv * env, jobject thiz)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
GST_DEBUG ("Quitting main loop...");
g_main_loop_quit (data->main_loop);
GST_DEBUG ("Waiting for thread to finish...");
pthread_join (gst_app_thread, NULL);
GST_DEBUG ("Deleting GlobalRef for app object at %p", data->app);
(*env)->DeleteGlobalRef (env, data->app);
GST_DEBUG ("Freeing CustomData at %p", data);
g_free (data);
SET_CUSTOM_DATA (env, thiz, custom_data_field_id, NULL);
GST_DEBUG ("Done finalizing");
}
/* Set pipeline to PLAYING state */
static void
gst_native_play (JNIEnv * env, jobject thiz)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
GST_DEBUG ("Setting state to PLAYING");
gst_element_set_state (data->pipeline, GST_STATE_PLAYING);
}
/* Set pipeline to PAUSED state */
static void
gst_native_pause (JNIEnv * env, jobject thiz)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
GST_DEBUG ("Setting state to PAUSED");
gst_element_set_state (data->pipeline, GST_STATE_PAUSED);
}
/* Static class initializer: retrieve method and field IDs */
static jboolean
gst_native_class_init (JNIEnv * env, jclass klass)
{
custom_data_field_id =
(*env)->GetFieldID (env, klass, "native_custom_data", "J");
set_message_method_id =
(*env)->GetMethodID (env, klass, "setMessage", "(Ljava/lang/String;)V");
on_gstreamer_initialized_method_id =
(*env)->GetMethodID (env, klass, "onGStreamerInitialized", "()V");
if (!custom_data_field_id || !set_message_method_id
|| !on_gstreamer_initialized_method_id) {
/* We emit this message through the Android log instead of the GStreamer log because the later
* has not been initialized yet.
*/
__android_log_print (ANDROID_LOG_ERROR, "vulkan-1",
"The calling class does not implement all necessary interface methods");
return JNI_FALSE;
}
return JNI_TRUE;
}
static void
gst_native_surface_init (JNIEnv * env, jobject thiz, jobject surface)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
ANativeWindow *new_native_window = ANativeWindow_fromSurface (env, surface);
GST_DEBUG ("Received surface %p (native window %p)", surface,
new_native_window);
if (data->native_window) {
ANativeWindow_release (data->native_window);
if (data->native_window == new_native_window) {
GST_DEBUG ("New native window is the same as the previous one %p",
data->native_window);
if (data->video_sink) {
gst_video_overlay_expose (GST_VIDEO_OVERLAY (data->video_sink));
gst_video_overlay_expose (GST_VIDEO_OVERLAY (data->video_sink));
}
return;
} else {
GST_DEBUG ("Released previous native window %p", data->native_window);
data->initialized = FALSE;
}
}
data->native_window = new_native_window;
check_initialization_complete (data);
}
static void
gst_native_surface_finalize (JNIEnv * env, jobject thiz)
{
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
GST_DEBUG ("Releasing Native Window %p", data->native_window);
if (data->video_sink) {
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (data->video_sink),
(guintptr) NULL);
gst_element_set_state (data->pipeline, GST_STATE_READY);
}
ANativeWindow_release (data->native_window);
data->native_window = NULL;
data->initialized = FALSE;
}
/* List of implemented native methods */
static JNINativeMethod native_methods[] = {
{"nativeInit", "()V", (void *) gst_native_init},
{"nativeFinalize", "()V", (void *) gst_native_finalize},
{"nativePlay", "()V", (void *) gst_native_play},
{"nativePause", "()V", (void *) gst_native_pause},
{"nativeSurfaceInit", "(Ljava/lang/Object;)V",
(void *) gst_native_surface_init},
{"nativeSurfaceFinalize", "()V", (void *) gst_native_surface_finalize},
{"nativeClassInit", "()Z", (void *) gst_native_class_init}
};
/* Library initializer */
jint
JNI_OnLoad (JavaVM * vm, void *reserved)
{
JNIEnv *env = NULL;
java_vm = vm;
if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) {
__android_log_print (ANDROID_LOG_ERROR, "vulkan-1",
"Could not retrieve JNIEnv");
return 0;
}
jclass klass = (*env)->FindClass (env,
"org/freedesktop/gstreamer/vulkan/Vulkan1");
(*env)->RegisterNatives (env, klass, native_methods,
G_N_ELEMENTS (native_methods));
pthread_key_create (&current_jni_env, detach_current_thread);
return JNI_VERSION_1_4;
}

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/textview_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:gravity="center_horizontal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/button_play"
android:src="@android:drawable/ic_media_play"
android:text="@string/button_play" />
<ImageButton
android:id="@+id/button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/button_stop"
android:src="@android:drawable/ic_media_pause"
android:text="@string/button_stop" />
</LinearLayout>
<org.freedesktop.gstreamer.vulkan.GStreamerSurfaceView
android:id="@+id/surface_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
</LinearLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GStreamer Vulkan 1</string>
<string name="button_play">Play</string>
<string name="button_stop">Stop</string>
</resources>

Some files were not shown because too many files have changed in this diff Show more