├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── fontconfig │ │ ├── fonts.conf │ │ └── fonts │ │ │ └── truetype │ │ │ └── Ubuntu-R.ttf │ └── ssl │ │ └── certs │ │ └── ca-certificates.crt │ ├── java │ └── org │ │ └── freedesktop │ │ └── gstreamer │ │ └── camera │ │ ├── CameraActivity.java │ │ └── GstAhc.java │ ├── jni │ ├── Android.mk │ ├── Application.mk │ ├── android_camera.c │ └── dummy.cpp │ └── res │ ├── layout │ ├── activity_main.xml │ ├── autofocus.xml │ ├── resolution.xml │ └── white_balance.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── photography.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots └── screenshot.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/* 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | (This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.) 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | {description} 474 | Copyright (C) {year} {fullname} 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | {signature of Ty Coon}, 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Announcement 2 | ------------ 3 | **Maintenance Notice**: As of May 2025, this repository (https://github.com/gstreamer101/gst-android-camera) will be actively maintained as the official fork of the original gst-android-camera project. We will provide regular updates, bug fixes, and support for modern Android versions. All future development and improvements for GStreamer Android camera integration will happen here. 4 | 5 | If you're using the previous repository, we recommend updating your references to this one. Feel free to open issues or contribute via pull requests to help improve this project. 6 | 7 | 8 | Example Android App for AHCSRC 9 | ============================== 10 | 11 | Prerequisite 12 | ------------ 13 | 14 | - Gstreamer SDK for Android (>=1.7.1) 15 | - Android Studio (>=2.3.3) 16 | - Android NDK (>=r15b) 17 | - Gradle (>=2.3.3) 18 | 19 | Build and Installation 20 | ---------------------- 21 | 22 | - Set GSTREAMER_ROOT_ANDROID evironment varible 23 | 24 | ``` 25 | $ export GSTREAMER_ROOT_ANDROID=/path/to/gstreamer/sdk 26 | ``` 27 | 28 | - Create `local.properties` and add `sdk.dir` and `ndk.dir` properties 29 | 30 | - Build with gradle 31 | 32 | ``` 33 | $ gradle build 34 | ``` 35 | 36 | - Install with gradle 37 | 38 | ``` 39 | $ gradle installDebug 40 | ``` 41 | 42 | Screenshots 43 | ---------- 44 | ![screenshot](screenshots/screenshot.png) 45 | 46 | Restrictions and Known bugs 47 | --------------------------- 48 | 49 | - ahcsrc element is a child element of GstPushSrc so it cannot be compatible 50 | with camerabin2 as it is. 51 | 52 | - No properties to set camera options like resolution, video formats. 53 | Each option can be set by caps filter. 54 | The options of real camera may vary on different android devices, so 55 | supported options should be analyzed on android application side. 56 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | gst-build-* 3 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.3" 6 | defaultConfig { 7 | applicationId "org.freedesktop.gstreamer.examples.camera" 8 | minSdkVersion 25 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | 14 | ndk { 15 | abiFilters 'armeabi-v7a', 'arm64-v8a' 16 | } 17 | 18 | externalNativeBuild { 19 | ndkBuild { 20 | def gstRoot 21 | 22 | targets "android_camera" 23 | 24 | if (project.hasProperty('gstAndroidRoot')) 25 | gstRoot = project.gstAndroidRoot 26 | else 27 | gstRoot = System.env.GSTREAMER_ROOT_ANDROID 28 | 29 | if (gstRoot == null) 30 | 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') 31 | 32 | arguments "NDK_APPLICATION_MK=src/main/jni/Application.mk", 33 | "GSTREAMER_JAVA_SRC_DIR=src/main/java", 34 | "GSTREAMER_ROOT_ANDROID=$gstRoot", 35 | "GSTREAMER_ASSETS_DIR=src/main/assets" 36 | } 37 | } 38 | } 39 | buildTypes { 40 | release { 41 | minifyEnabled false 42 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 43 | } 44 | } 45 | 46 | externalNativeBuild { 47 | ndkBuild { 48 | path 'src/main/jni/Android.mk' 49 | } 50 | } 51 | productFlavors { 52 | } 53 | } 54 | 55 | dependencies { 56 | implementation fileTree(include: ['*.jar'], dir: 'libs') 57 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { 58 | exclude group: 'com.android.support', module: 'support-annotations' 59 | }) 60 | implementation 'com.android.support:appcompat-v7:28.0.0' 61 | implementation 'com.android.support:support-v13:28.0.0' 62 | testImplementation 'junit:junit:4.12' 63 | } 64 | 65 | afterEvaluate { 66 | compileDebugJavaWithJavac.dependsOn 'externalNativeBuildDebug' 67 | compileReleaseJavaWithJavac.dependsOn 'externalNativeBuildRelease' 68 | } 69 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/justin/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/assets/fontconfig/fonts.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | fontconfig/fonts 9 | 10 | 11 | 12 | fontconfig 13 | 14 | 17 | 18 | 19 | mono 20 | 21 | 22 | monospace 23 | 24 | 25 | 26 | 29 | 30 | 31 | sans serif 32 | 33 | 34 | sans-serif 35 | 36 | 37 | 38 | 41 | 42 | 43 | sans 44 | 45 | 46 | sans-serif 47 | 48 | 49 | 50 | 51 | 56 | 57 | 0x0020 58 | 0x00A0 59 | 0x00AD 60 | 0x034F 61 | 0x0600 62 | 0x0601 63 | 0x0602 64 | 0x0603 65 | 0x06DD 66 | 0x070F 67 | 0x115F 68 | 0x1160 69 | 0x1680 70 | 0x17B4 71 | 0x17B5 72 | 0x180E 73 | 0x2000 74 | 0x2001 75 | 0x2002 76 | 0x2003 77 | 0x2004 78 | 0x2005 79 | 0x2006 80 | 0x2007 81 | 0x2008 82 | 0x2009 83 | 0x200A 84 | 0x200B 85 | 0x200C 86 | 0x200D 87 | 0x200E 88 | 0x200F 89 | 0x2028 90 | 0x2029 91 | 0x202A 92 | 0x202B 93 | 0x202C 94 | 0x202D 95 | 0x202E 96 | 0x202F 97 | 0x205F 98 | 0x2060 99 | 0x2061 100 | 0x2062 101 | 0x2063 102 | 0x206A 103 | 0x206B 104 | 0x206C 105 | 0x206D 106 | 0x206E 107 | 0x206F 108 | 0x2800 109 | 0x3000 110 | 0x3164 111 | 0xFEFF 112 | 0xFFA0 113 | 0xFFF9 114 | 0xFFFA 115 | 0xFFFB 116 | 117 | 120 | 121 | 30 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /app/src/main/assets/fontconfig/fonts/truetype/Ubuntu-R.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/assets/fontconfig/fonts/truetype/Ubuntu-R.ttf -------------------------------------------------------------------------------- /app/src/main/java/org/freedesktop/gstreamer/camera/CameraActivity.java: -------------------------------------------------------------------------------- 1 | package org.freedesktop.gstreamer.camera; 2 | 3 | import android.Manifest; 4 | import android.annotation.SuppressLint; 5 | import android.content.pm.PackageManager; 6 | import android.content.res.Configuration; 7 | import android.os.Bundle; 8 | import android.os.Handler; 9 | import android.support.v4.app.ActivityCompat; 10 | import android.support.v4.content.ContextCompat; 11 | import android.support.v7.app.ActionBar; 12 | import android.support.v7.app.AppCompatActivity; 13 | import android.util.Log; 14 | import android.view.MotionEvent; 15 | import android.view.Surface; 16 | import android.view.SurfaceView; 17 | import android.view.View; 18 | import android.widget.AdapterView; 19 | import android.widget.CheckBox; 20 | import android.widget.ImageButton; 21 | import android.widget.RadioButton; 22 | import android.widget.Spinner; 23 | import android.widget.Toast; 24 | 25 | import org.freedesktop.gstreamer.examples.camera.R; 26 | 27 | /** 28 | * An example full-screen activity that shows and hides the system UI (i.e. 29 | * status bar and navigation/system bar) with user interaction. 30 | */ 31 | public class CameraActivity extends AppCompatActivity { 32 | 33 | private static final int PERMISSION_REQUEST_CAMERA = 1; 34 | 35 | private GstAhc gstAhc; 36 | /** 37 | * Whether or not the system UI should be auto-hidden after 38 | * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds. 39 | */ 40 | private static final boolean AUTO_HIDE = true; 41 | 42 | /** 43 | * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after 44 | * user interaction before hiding the system UI. 45 | */ 46 | private static final int AUTO_HIDE_DELAY_MILLIS = 3000; 47 | 48 | /** 49 | * Some older devices needs a small delay between UI widget updates 50 | * and a change of the status and navigation bar. 51 | */ 52 | private static final int UI_ANIMATION_DELAY = 300; 53 | private final Handler mHideHandler = new Handler(); 54 | private SurfaceView surfaceView; 55 | private ImageButton playButton; 56 | private final Runnable mHidePart2Runnable = new Runnable() { 57 | @SuppressLint("InlinedApi") 58 | @Override 59 | public void run() { 60 | // Delayed removal of status and navigation bar 61 | 62 | // Note that some of these constants are new as of API 16 (Jelly Bean) 63 | // and API 19 (KitKat). It is safe to use them, as they are inlined 64 | // at compile-time and do nothing on earlier devices. 65 | surfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE 66 | | View.SYSTEM_UI_FLAG_FULLSCREEN 67 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE 68 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY 69 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 70 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); 71 | } 72 | }; 73 | private View mControlsView; 74 | private final Runnable mShowPart2Runnable = new Runnable() { 75 | @Override 76 | public void run() { 77 | // Delayed display of UI elements 78 | ActionBar actionBar = getSupportActionBar(); 79 | if (actionBar != null) { 80 | actionBar.show(); 81 | } 82 | mControlsView.setVisibility(View.VISIBLE); 83 | } 84 | }; 85 | private boolean mVisible; 86 | private final Runnable mHideRunnable = new Runnable() { 87 | @Override 88 | public void run() { 89 | hide(); 90 | } 91 | }; 92 | /** 93 | * Touch listener to use for in-layout UI controls to delay hiding the 94 | * system UI. This is to prevent the jarring behavior of controls going away 95 | * while interacting with activity UI. 96 | */ 97 | private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() { 98 | @Override 99 | public boolean onTouch(View view, MotionEvent motionEvent) { 100 | if (AUTO_HIDE) { 101 | delayedHide(AUTO_HIDE_DELAY_MILLIS); 102 | } 103 | return false; 104 | } 105 | }; 106 | 107 | @Override 108 | protected void onCreate(Bundle savedInstanceState) { 109 | super.onCreate(savedInstanceState); 110 | 111 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { 112 | 113 | ActivityCompat.requestPermissions( 114 | this, 115 | new String[] { Manifest.permission.CAMERA }, 116 | PERMISSION_REQUEST_CAMERA); 117 | return; 118 | } 119 | try { 120 | gstAhc = GstAhc.init(this); 121 | } catch (Exception e) { 122 | Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); 123 | } 124 | 125 | setContentView(R.layout.activity_main); 126 | 127 | mVisible = true; 128 | mControlsView = findViewById(R.id.fullscreen_content_controls); 129 | surfaceView = (SurfaceView) findViewById(R.id.surface_view); 130 | playButton = (ImageButton) findViewById(R.id.play_button); 131 | 132 | // Set up the user interaction to manually show or hide the system UI. 133 | surfaceView.setOnClickListener(new View.OnClickListener() { 134 | @Override 135 | public void onClick(View view) { 136 | toggle(); 137 | } 138 | }); 139 | 140 | Spinner spinner = (Spinner) findViewById(R.id.white_balance_spinner); 141 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 142 | @Override 143 | public void onItemSelected(AdapterView parent, View view, int pos, long id) { 144 | gstAhc.setWhiteBalanceMode (parent.getItemAtPosition(pos).toString()); 145 | } 146 | 147 | @Override 148 | public void onNothingSelected(AdapterView parent) { 149 | ; // do nothing 150 | } 151 | }); 152 | 153 | playButton.setOnClickListener(new View.OnClickListener() { 154 | @Override 155 | public void onClick(View view) { 156 | Log.d("CameraActivity", "clicked button"); 157 | gstAhc.togglePlay(); 158 | } 159 | }); 160 | 161 | gstAhc.setStateChangedListener(new GstAhc.StateChangedListener(){ 162 | @Override 163 | public void stateChanged(GstAhc gstAhc, final GstAhc.State state) { 164 | playButton = (ImageButton) findViewById(R.id.play_button); 165 | 166 | CameraActivity.this.runOnUiThread(new Runnable() { 167 | @Override 168 | public void run() { 169 | if (state != GstAhc.State.PLAYING) { 170 | playButton.setImageResource(android.R.drawable.ic_media_play); 171 | } 172 | else { 173 | playButton.setImageResource(android.R.drawable.ic_media_pause); 174 | } 175 | } 176 | }); 177 | 178 | } 179 | }); 180 | 181 | gstAhc.setErrorListener(new GstAhc.ErrorListener(){ 182 | @Override 183 | public void error(GstAhc gstAhc, String errorMessage) { 184 | Toast.makeText(CameraActivity.this, errorMessage, Toast.LENGTH_LONG).show(); 185 | } 186 | }); 187 | 188 | surfaceView.getHolder().addCallback(gstAhc); 189 | 190 | setOrientation (this.getWindowManager().getDefaultDisplay() 191 | .getRotation()); 192 | } 193 | 194 | @Override 195 | protected void onPostCreate(Bundle savedInstanceState) { 196 | super.onPostCreate(savedInstanceState); 197 | 198 | // Trigger the initial hide() shortly after the activity has been 199 | // created, to briefly hint to the user that UI controls 200 | // are available. 201 | delayedHide(100); 202 | } 203 | 204 | private void toggle() { 205 | if (mVisible) { 206 | hide(); 207 | } else { 208 | show(); 209 | } 210 | } 211 | 212 | private void hide() { 213 | // Hide UI first 214 | ActionBar actionBar = getSupportActionBar(); 215 | if (actionBar != null) { 216 | actionBar.hide(); 217 | } 218 | mControlsView.setVisibility(View.GONE); 219 | mVisible = false; 220 | 221 | // Schedule a runnable to remove the status and navigation bar after a delay 222 | mHideHandler.removeCallbacks(mShowPart2Runnable); 223 | mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY); 224 | } 225 | 226 | @SuppressLint("InlinedApi") 227 | private void show() { 228 | // Show the system bar 229 | surfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 230 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); 231 | mVisible = true; 232 | 233 | // Schedule a runnable to display UI elements after a delay 234 | mHideHandler.removeCallbacks(mHidePart2Runnable); 235 | mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY); 236 | } 237 | 238 | /** 239 | * Schedules a call to hide() in [delay] milliseconds, canceling any 240 | * previously scheduled calls. 241 | */ 242 | private void delayedHide(int delayMillis) { 243 | mHideHandler.removeCallbacks(mHideRunnable); 244 | mHideHandler.postDelayed(mHideRunnable, delayMillis); 245 | } 246 | 247 | public void onRadioButtonClicked(View view) { 248 | // Is the button now checked? 249 | boolean checked = ((RadioButton) view).isChecked(); 250 | 251 | // Check which radio button was clicked 252 | switch(view.getId()) { 253 | case R.id.radio_resolution_320: 254 | if (checked) { 255 | gstAhc.changeResolutionTo(320, 240); 256 | } 257 | break; 258 | case R.id.radio_resolution_640: 259 | if (checked) { 260 | gstAhc.changeResolutionTo(640, 480); 261 | } 262 | break; 263 | } 264 | } 265 | 266 | public void onCheckboxClicked(View view) { 267 | boolean checked = ((CheckBox) view).isChecked(); 268 | 269 | switch(view.getId()) { 270 | case R.id.autofocus: 271 | gstAhc.setAutoFocus(checked); 272 | break; 273 | default: 274 | break; 275 | } 276 | } 277 | 278 | private void setOrientation (int rotation) 279 | { 280 | GstAhc.Rotate rotate = GstAhc.Rotate.NONE; 281 | 282 | switch (rotation) { 283 | case Surface.ROTATION_0: rotate = GstAhc.Rotate.COUNTERCLOCKWISE; break; 284 | case Surface.ROTATION_90: rotate = GstAhc.Rotate.ROTATE_180; break; 285 | case Surface.ROTATION_180: rotate = GstAhc.Rotate.NONE; break; 286 | case Surface.ROTATION_270: rotate = GstAhc.Rotate.NONE; break; 287 | } 288 | 289 | gstAhc.setRotateMethod(rotate); 290 | } 291 | 292 | @Override 293 | public void onConfigurationChanged(Configuration newConfig) { 294 | super.onConfigurationChanged(newConfig); 295 | 296 | if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) 297 | { 298 | Toast.makeText(this,"PORTRAIT",Toast.LENGTH_LONG).show(); 299 | } 300 | else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) 301 | { 302 | Toast.makeText(this,"LANDSCAPE",Toast.LENGTH_LONG).show(); 303 | } 304 | 305 | setOrientation (this.getWindowManager().getDefaultDisplay() 306 | .getRotation()); 307 | } 308 | } 309 | -------------------------------------------------------------------------------- /app/src/main/java/org/freedesktop/gstreamer/camera/GstAhc.java: -------------------------------------------------------------------------------- 1 | package org.freedesktop.gstreamer.camera; 2 | 3 | import android.content.Context; 4 | import android.hardware.Camera; 5 | import android.util.Log; 6 | import android.view.SurfaceHolder; 7 | 8 | import org.freedesktop.gstreamer.GStreamer; 9 | 10 | import java.io.Closeable; 11 | import java.io.IOException; 12 | import java.util.Arrays; 13 | 14 | public class GstAhc implements Closeable, SurfaceHolder.Callback { 15 | 16 | private final static String TAG = GstAhc.class.getName(); 17 | 18 | private native void nativeInit(); 19 | 20 | private native void nativeFinalize(); 21 | 22 | private native void nativePlay(); 23 | 24 | private native void nativePause(); 25 | 26 | private static native boolean nativeClassInit(); 27 | 28 | private native void nativeSurfaceInit(Object surface); 29 | 30 | private native void nativeSurfaceFinalize(); 31 | 32 | private native void nativeChangeResolution(int width, int height); 33 | 34 | private native void nativeSetRotateMethod(int orientation); 35 | 36 | private native void nativeSetAutoFocus(boolean enabled); 37 | 38 | public enum Rotate { 39 | NONE, 40 | CLOCKWISE, 41 | ROTATE_180, 42 | COUNTERCLOCKWISE, 43 | HORIZONTAL_FLIP, 44 | VERTICAL_FLIP, 45 | UPPER_LEFT_DIAGONAL, 46 | UPPER_RIGHT_DIAGONAL, 47 | AUTOMATIC 48 | } 49 | 50 | private static final Rotate[] rotateMap = { 51 | Rotate.NONE, 52 | Rotate.CLOCKWISE, 53 | Rotate.ROTATE_180, 54 | Rotate.COUNTERCLOCKWISE, 55 | Rotate.HORIZONTAL_FLIP, 56 | Rotate.VERTICAL_FLIP, 57 | Rotate.UPPER_LEFT_DIAGONAL, 58 | Rotate.UPPER_RIGHT_DIAGONAL, 59 | Rotate.AUTOMATIC 60 | }; 61 | 62 | private static final String[] whiteBalanceMap = { 63 | Camera.Parameters.WHITE_BALANCE_AUTO, 64 | Camera.Parameters.WHITE_BALANCE_DAYLIGHT, 65 | Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT, 66 | Camera.Parameters.WHITE_BALANCE_TWILIGHT, 67 | Camera.Parameters.WHITE_BALANCE_INCANDESCENT, 68 | Camera.Parameters.WHITE_BALANCE_FLUORESCENT, 69 | "manual", 70 | Camera.Parameters.WHITE_BALANCE_WARM_FLUORESCENT, 71 | Camera.Parameters.WHITE_BALANCE_SHADE 72 | }; 73 | 74 | private native void nativeSetWhiteBalance(int wb); 75 | 76 | private long native_custom_data; 77 | 78 | private String whiteBalanceMode; 79 | private Context context; 80 | 81 | private GstAhc(Context context) { 82 | nativeInit(); 83 | this.context = context; 84 | } 85 | 86 | public static GstAhc init(Context context) throws Exception { 87 | 88 | System.loadLibrary("gstreamer_android"); 89 | System.loadLibrary("android_camera"); 90 | 91 | GStreamer.init(context); 92 | 93 | if (!nativeClassInit()) { 94 | throw new Exception("Failed to load application jni library."); 95 | } 96 | 97 | return new GstAhc(context); 98 | } 99 | 100 | private static final State[] stateMap = { 101 | State.VOID, 102 | State.NULL, 103 | State.READY, 104 | State.PAUSED, 105 | State.PLAYING 106 | }; 107 | 108 | public enum State { 109 | VOID, 110 | NULL, 111 | READY, 112 | PAUSED, 113 | PLAYING 114 | } 115 | 116 | private State state = State.VOID; 117 | 118 | public static interface StateChangedListener { 119 | abstract void stateChanged(GstAhc gstAhc, State state); 120 | } 121 | 122 | private StateChangedListener stateChangedListener; 123 | 124 | public void setStateChangedListener(StateChangedListener listener) { 125 | stateChangedListener = listener; 126 | } 127 | 128 | private void onStateChanged(int stateIdx) { 129 | if (stateChangedListener != null) { 130 | state = stateMap[stateIdx]; 131 | stateChangedListener.stateChanged(this, state); 132 | } 133 | } 134 | 135 | public void togglePlay() { 136 | if (state == State.PLAYING) { 137 | nativePause(); 138 | } else { 139 | nativePlay(); 140 | } 141 | } 142 | 143 | @Override 144 | public void surfaceCreated(SurfaceHolder surfaceHolder) { 145 | Log.d(TAG, "Surface created: " + surfaceHolder.getSurface()); 146 | } 147 | 148 | @Override 149 | public void surfaceChanged(SurfaceHolder surfaceHolder, int format, int width, int height) { 150 | Log.d(TAG, "Surface changed to format " + format + " width " 151 | + width + " height " + height); 152 | nativeSurfaceInit(surfaceHolder.getSurface()); 153 | 154 | } 155 | 156 | @Override 157 | public void surfaceDestroyed(SurfaceHolder surfaceHolder) { 158 | Log.d(TAG, "Surface destroyed"); 159 | nativeSurfaceFinalize(); 160 | } 161 | 162 | public void setAutoFocus(boolean enabled) { 163 | Log.d(TAG, "AutoFocus: " + enabled); 164 | nativeSetAutoFocus (enabled); 165 | } 166 | 167 | public void setWhiteBalanceMode(String mode) { 168 | Log.d(TAG, "WhiteBlanceMode: " + mode); 169 | 170 | int idx = Arrays.asList(whiteBalanceMap).indexOf(mode); 171 | 172 | if (idx == -1 || idx >= whiteBalanceMap.length) { 173 | Log.d(TAG, "Invalid white balance mode. Try to use 'auto'"); 174 | idx = 0; 175 | } 176 | 177 | nativeSetWhiteBalance(idx); 178 | } 179 | 180 | public void setRotateMethod(Rotate rotate) { 181 | nativeSetRotateMethod(Arrays.asList(rotateMap).indexOf(rotate)); 182 | } 183 | 184 | public void changeResolutionTo(int width, int height) { 185 | Log.d(TAG, "Trying to set resolution to (w: " + width + " h: " + height + ")"); 186 | nativePause(); 187 | 188 | nativeChangeResolution(width, height); 189 | 190 | nativePlay(); 191 | } 192 | 193 | @Override 194 | public void close() throws IOException { 195 | nativeFinalize(); 196 | } 197 | 198 | /* Called from native code */ 199 | private void onGStreamerInitialized() { 200 | Log.d(TAG, "Playing Camera!"); 201 | nativePlay(); 202 | } 203 | 204 | public static interface ErrorListener { 205 | abstract void error(GstAhc gstAhc, String errorMessage); 206 | } 207 | 208 | private ErrorListener errorListener; 209 | 210 | public void setErrorListener(ErrorListener listener) { 211 | errorListener = listener; 212 | } 213 | 214 | private void onError(String errorMessage) { 215 | if (errorListener != null) { 216 | errorListener.error(this, errorMessage); 217 | } 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /app/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012, Collabora Ltd. 3 | # Author: Youness Alaoui 4 | # 5 | # Copyright (C) 2016-2017, Collabora Ltd. 6 | # Author: Justin Kim 7 | # 8 | # This library is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Lesser General Public 10 | # License as published by the Free Software Foundation 11 | # version 2.1 of the License. 12 | # 13 | # This library is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public 19 | # License along with this library; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | 22 | LOCAL_PATH := $(call my-dir) 23 | 24 | include $(CLEAR_VARS) 25 | 26 | LOCAL_CFLAGS := -DGST_USE_UNSTABLE_API 27 | LOCAL_MODULE := android_camera 28 | LOCAL_SRC_FILES := android_camera.c dummy.cpp 29 | LOCAL_SHARED_LIBRARIES := gstreamer_android 30 | LOCAL_LDLIBS := -llog -landroid 31 | include $(BUILD_SHARED_LIBRARY) 32 | 33 | ifeq ($(TARGET_ARCH_ABI),armeabi) 34 | GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/arm 35 | else ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 36 | GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/armv7 37 | else ifeq ($(TARGET_ARCH_ABI),arm64-v8a) 38 | GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/arm64 39 | else ifeq ($(TARGET_ARCH_ABI),x86) 40 | GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/x86 41 | else ifeq ($(TARGET_ARCH_ABI),x86_64) 42 | GSTREAMER_ROOT := $(GSTREAMER_ROOT_ANDROID)/x86_64 43 | else 44 | $(error Target arch ABI not supported: $(TARGET_ARCH_ABI)) 45 | endif 46 | 47 | GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/ 48 | 49 | include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk 50 | GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) \ 51 | $(GSTREAMER_PLUGINS_PLAYBACK) \ 52 | $(GSTREAMER_PLUGINS_CODECS) \ 53 | opengl 54 | 55 | # Needed for new versions of gstreamer 56 | GSTREAMER_EXTRA_DEPS := gstreamer-video-1.0 gstreamer-photography-1.0 57 | include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer-1.0.mk 58 | -------------------------------------------------------------------------------- /app/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017, Collabora Ltd. 3 | # Author: Justin Kim 4 | # 5 | # This library is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU Lesser General Public 7 | # License as published by the Free Software Foundation 8 | # version 2.1 of the License. 9 | # 10 | # This library is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with this library; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | # APP_ABI = armeabi-v7a 20 | APP_ABI = x86 x86_64 21 | 22 | # Gstreamer is using the C++ library that must be included in the APK 23 | APP_STL = c++_shared 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/jni/android_camera.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012, Collabora Ltd. 3 | * Author: Youness Alaoui 4 | * 5 | * Copyright (C) 2016-2017, Collabora Ltd. 6 | * Author: Justin Kim 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation 11 | * version 2.1 of the License. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | GST_DEBUG_CATEGORY_STATIC (debug_category); 35 | #define GST_CAT_DEFAULT debug_category 36 | 37 | /* 38 | * These macros provide a way to store the native pointer to GstAhc, which might be 32 or 64 bits, into 39 | * a jlong, which is always 64 bits, without warnings. 40 | */ 41 | #if GLIB_SIZEOF_VOID_P == 8 42 | # define GET_CUSTOM_DATA(env, thiz, fieldID) (GstAhc *)(*env)->GetLongField (env, thiz, fieldID) 43 | # define SET_CUSTOM_DATA(env, thiz, fieldID, data) (*env)->SetLongField (env, thiz, fieldID, (jlong)data) 44 | #else 45 | # define GET_CUSTOM_DATA(env, thiz, fieldID) (GstAhc *)(jint)(*env)->GetLongField (env, thiz, fieldID) 46 | # define SET_CUSTOM_DATA(env, thiz, fieldID, data) (*env)->SetLongField (env, thiz, fieldID, (jlong)(jint)data) 47 | #endif 48 | 49 | typedef struct _GstAhc 50 | { 51 | jobject app; 52 | GstElement *pipeline; 53 | GMainLoop *main_loop; 54 | ANativeWindow *native_window; 55 | gboolean state; 56 | GstElement *ahcsrc; 57 | GstElement *filter; 58 | GstElement *vsink; 59 | gboolean initialized; 60 | } GstAhc; 61 | 62 | static pthread_t gst_app_thread; 63 | static pthread_key_t current_jni_env; 64 | static JavaVM *java_vm; 65 | static jfieldID native_android_camera_field_id; 66 | static jmethodID on_error_method_id; 67 | static jmethodID on_state_changed_method_id; 68 | static jmethodID on_gstreamer_initialized_method_id; 69 | 70 | /* 71 | * Private methods 72 | */ 73 | static JNIEnv * 74 | attach_current_thread (void) 75 | { 76 | JNIEnv *env; 77 | JavaVMAttachArgs args; 78 | 79 | GST_DEBUG ("Attaching thread %p", g_thread_self ()); 80 | args.version = JNI_VERSION_1_4; 81 | args.name = NULL; 82 | args.group = NULL; 83 | 84 | if ((*java_vm)->AttachCurrentThread (java_vm, &env, &args) < 0) { 85 | GST_ERROR ("Failed to attach current thread"); 86 | return NULL; 87 | } 88 | 89 | return env; 90 | } 91 | 92 | static void 93 | detach_current_thread (void *env) 94 | { 95 | GST_DEBUG ("Detaching thread %p", g_thread_self ()); 96 | (*java_vm)->DetachCurrentThread (java_vm); 97 | } 98 | 99 | static JNIEnv * 100 | get_jni_env (void) 101 | { 102 | JNIEnv *env; 103 | 104 | if ((env = pthread_getspecific (current_jni_env)) == NULL) { 105 | env = attach_current_thread (); 106 | pthread_setspecific (current_jni_env, env); 107 | } 108 | 109 | return env; 110 | } 111 | 112 | static void 113 | on_error (GstBus * bus, GstMessage * message, GstAhc * ahc) 114 | { 115 | gchar *message_string; 116 | GError *err; 117 | gchar *debug_info; 118 | jstring jmessage; 119 | JNIEnv *env = get_jni_env (); 120 | 121 | gst_message_parse_error (message, &err, &debug_info); 122 | message_string = 123 | g_strdup_printf ("Error received from element %s: %s", 124 | GST_OBJECT_NAME (message->src), err->message); 125 | 126 | g_clear_error (&err); 127 | g_free (debug_info); 128 | 129 | jmessage = (*env)->NewStringUTF (env, message_string); 130 | 131 | (*env)->CallVoidMethod (env, ahc->app, on_error_method_id, jmessage); 132 | if ((*env)->ExceptionCheck (env)) { 133 | GST_ERROR ("Failed to call Java method"); 134 | (*env)->ExceptionClear (env); 135 | } 136 | (*env)->DeleteLocalRef (env, jmessage); 137 | 138 | g_free (message_string); 139 | gst_element_set_state (ahc->pipeline, GST_STATE_NULL); 140 | } 141 | 142 | 143 | static void 144 | eos_cb (GstBus * bus, GstMessage * msg, GstAhc * data) 145 | { 146 | gst_element_set_state (data->pipeline, GST_STATE_PAUSED); 147 | } 148 | 149 | static void 150 | state_changed_cb (GstBus * bus, GstMessage * msg, GstAhc * ahc) 151 | { 152 | JNIEnv *env = get_jni_env (); 153 | GstState old_state, new_state, pending_state; 154 | 155 | gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); 156 | /* Only pay attention to messages coming from the pipeline, not its children */ 157 | if (GST_MESSAGE_SRC (msg) == GST_OBJECT (ahc->pipeline)) { 158 | ahc->state = new_state; 159 | GST_DEBUG ("State changed to %s, notifying application", 160 | gst_element_state_get_name (new_state)); 161 | (*env)->CallVoidMethod (env, ahc->app, on_state_changed_method_id, 162 | new_state); 163 | if ((*env)->ExceptionCheck (env)) { 164 | (*env)->ExceptionDescribe (env); 165 | GST_ERROR ("Failed to call Java method"); 166 | (*env)->ExceptionClear (env); 167 | } 168 | } 169 | } 170 | 171 | static void 172 | check_initialization_complete (GstAhc * data) 173 | { 174 | JNIEnv *env = get_jni_env (); 175 | /* Check if all conditions are met to report GStreamer as initialized. 176 | * These conditions will change depending on the application */ 177 | if (!data->initialized && data->native_window && data->main_loop) { 178 | GST_DEBUG 179 | ("Initialization complete, notifying application. native_window:%p main_loop:%p", 180 | data->native_window, data->main_loop); 181 | data->initialized = TRUE; 182 | (*env)->CallVoidMethod (env, data->app, on_gstreamer_initialized_method_id); 183 | if ((*env)->ExceptionCheck (env)) { 184 | GST_ERROR ("Failed to call Java method"); 185 | (*env)->ExceptionClear (env); 186 | } 187 | } 188 | } 189 | 190 | static void * 191 | app_function (void *userdata) 192 | { 193 | JavaVMAttachArgs args; 194 | GstBus *bus; 195 | GstMessage *msg; 196 | GstAhc *ahc = (GstAhc *) userdata; 197 | GSource *bus_source; 198 | GMainContext *context; 199 | 200 | GST_DEBUG ("Creating pipeline in GstAhc at %p", ahc); 201 | 202 | /* create our own GLib Main Context, so we do not interfere with other libraries using GLib */ 203 | context = g_main_context_new (); 204 | 205 | ahc->ahcsrc = gst_element_factory_make ("ahcsrc", "ahcsrc"); 206 | ahc->vsink = gst_element_factory_make ("glimagesink", "vsink"); 207 | ahc->filter = gst_element_factory_make ("capsfilter", NULL); 208 | 209 | ahc->pipeline = gst_pipeline_new ("camera-pipeline"); 210 | 211 | gst_bin_add_many (GST_BIN (ahc->pipeline), 212 | ahc->ahcsrc, 213 | ahc->filter, 214 | ahc->vsink, 215 | NULL); 216 | 217 | gst_element_link_many (ahc->ahcsrc, ahc->filter, ahc->vsink, NULL); 218 | 219 | if (ahc->native_window) { 220 | GST_DEBUG ("Native window already received, notifying the vsink about it."); 221 | gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (ahc->vsink), 222 | (guintptr) ahc->native_window); 223 | } 224 | 225 | /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ 226 | bus = gst_element_get_bus (ahc->pipeline); 227 | bus_source = gst_bus_create_watch (bus); 228 | g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, 229 | NULL, NULL); 230 | g_source_attach (bus_source, context); 231 | g_source_unref (bus_source); 232 | g_signal_connect (G_OBJECT (bus), "message::error", G_CALLBACK (on_error), 233 | ahc); 234 | g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb, ahc); 235 | g_signal_connect (G_OBJECT (bus), "message::state-changed", 236 | (GCallback) state_changed_cb, ahc); 237 | gst_object_unref (bus); 238 | 239 | /* Create a GLib Main Loop and set it to run */ 240 | GST_DEBUG ("Entering main loop... (GstAhc:%p)", ahc); 241 | ahc->main_loop = g_main_loop_new (context, FALSE); 242 | check_initialization_complete (ahc); 243 | g_main_loop_run (ahc->main_loop); 244 | GST_DEBUG ("Exited main loop"); 245 | g_main_loop_unref (ahc->main_loop); 246 | ahc->main_loop = NULL; 247 | 248 | /* Free resources */ 249 | g_main_context_unref (context); 250 | gst_element_set_state (ahc->pipeline, GST_STATE_NULL); 251 | gst_object_unref (ahc->vsink); 252 | gst_object_unref (ahc->filter); 253 | gst_object_unref (ahc->ahcsrc); 254 | gst_object_unref (ahc->pipeline); 255 | 256 | return NULL; 257 | } 258 | 259 | /* 260 | * Java Bindings 261 | */ 262 | void 263 | gst_native_init (JNIEnv * env, jobject thiz) 264 | { 265 | GstAhc *data = (GstAhc *) g_malloc0 (sizeof (GstAhc)); 266 | 267 | SET_CUSTOM_DATA (env, thiz, native_android_camera_field_id, data); 268 | GST_DEBUG ("Created GstAhc at %p", data); 269 | data->app = (*env)->NewGlobalRef (env, thiz); 270 | GST_DEBUG ("Created GlobalRef for app object at %p", data->app); 271 | pthread_create (&gst_app_thread, NULL, &app_function, data); 272 | } 273 | 274 | void 275 | gst_native_finalize (JNIEnv * env, jobject thiz) 276 | { 277 | GstAhc *data = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 278 | 279 | if (!data) 280 | return; 281 | GST_DEBUG ("Quitting main loop..."); 282 | g_main_loop_quit (data->main_loop); 283 | GST_DEBUG ("Waiting for thread to finish..."); 284 | pthread_join (gst_app_thread, NULL); 285 | GST_DEBUG ("Deleting GlobalRef at %p", data->app); 286 | (*env)->DeleteGlobalRef (env, data->app); 287 | GST_DEBUG ("Freeing GstAhc at %p", data); 288 | g_free (data); 289 | SET_CUSTOM_DATA (env, thiz, native_android_camera_field_id, NULL); 290 | GST_DEBUG ("Done finalizing"); 291 | } 292 | 293 | void 294 | gst_native_play (JNIEnv * env, jobject thiz) 295 | { 296 | GstAhc *data = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 297 | 298 | if (!data) 299 | return; 300 | GST_DEBUG ("Setting state to PLAYING"); 301 | gst_element_set_state (data->pipeline, GST_STATE_PLAYING); 302 | } 303 | 304 | void 305 | gst_native_pause (JNIEnv * env, jobject thiz) 306 | { 307 | GstAhc *data = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 308 | 309 | if (!data) 310 | return; 311 | GST_DEBUG ("Setting state to PAUSED"); 312 | gst_element_set_state (data->pipeline, GST_STATE_PAUSED); 313 | } 314 | 315 | jboolean 316 | gst_class_init (JNIEnv * env, jclass klass) 317 | { 318 | native_android_camera_field_id = 319 | (*env)->GetFieldID (env, klass, "native_custom_data", "J"); 320 | GST_DEBUG ("The FieldID for the native_custom_data field is %p", 321 | native_android_camera_field_id); 322 | on_error_method_id = 323 | (*env)->GetMethodID (env, klass, "onError", "(Ljava/lang/String;)V"); 324 | GST_DEBUG ("The MethodID for the onError method is %p", on_error_method_id); 325 | on_gstreamer_initialized_method_id = 326 | (*env)->GetMethodID (env, klass, "onGStreamerInitialized", "()V"); 327 | GST_DEBUG ("The MethodID for the onGStreamerInitialized method is %p", 328 | on_gstreamer_initialized_method_id); 329 | on_state_changed_method_id = 330 | (*env)->GetMethodID (env, klass, "onStateChanged", "(I)V"); 331 | GST_DEBUG ("The MethodID for the onStateChanged method is %p", 332 | on_state_changed_method_id); 333 | 334 | if (!native_android_camera_field_id || !on_error_method_id || 335 | !on_gstreamer_initialized_method_id || !on_state_changed_method_id) { 336 | GST_ERROR 337 | ("The calling class does not implement all necessary interface methods"); 338 | return JNI_FALSE; 339 | } 340 | return JNI_TRUE; 341 | } 342 | 343 | void 344 | gst_native_surface_init (JNIEnv * env, jobject thiz, jobject surface) 345 | { 346 | GstAhc *ahc = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 347 | 348 | if (!ahc) 349 | return; 350 | 351 | GST_DEBUG ("Received surface %p", surface); 352 | if (ahc->native_window) { 353 | GST_DEBUG ("Releasing previous native window %p", ahc->native_window); 354 | ANativeWindow_release (ahc->native_window); 355 | } 356 | ahc->native_window = ANativeWindow_fromSurface (env, surface); 357 | GST_DEBUG ("Got Native Window %p", ahc->native_window); 358 | 359 | if (ahc->vsink) { 360 | GST_DEBUG 361 | ("Pipeline already created, notifying the vsink about the native window."); 362 | gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (ahc->vsink), 363 | (guintptr) ahc->native_window); 364 | } else { 365 | GST_DEBUG 366 | ("Pipeline not created yet, vsink will later be notified about the native window."); 367 | } 368 | 369 | check_initialization_complete (ahc); 370 | } 371 | 372 | void 373 | gst_native_surface_finalize (JNIEnv * env, jobject thiz) 374 | { 375 | GstAhc *data = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 376 | 377 | if (!data) { 378 | GST_WARNING ("Received surface finalize but there is no GstAhc. Ignoring."); 379 | return; 380 | } 381 | GST_DEBUG ("Releasing Native Window %p", data->native_window); 382 | ANativeWindow_release (data->native_window); 383 | data->native_window = NULL; 384 | 385 | gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (data->vsink), 386 | (guintptr) NULL); 387 | } 388 | 389 | void 390 | gst_native_change_resolution (JNIEnv * env, jobject thiz, jint width, jint height) 391 | { 392 | GstCaps *new_caps; 393 | GstAhc *ahc = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 394 | 395 | if (!ahc) 396 | return; 397 | 398 | gst_element_set_state (ahc->pipeline, GST_STATE_READY); 399 | 400 | new_caps = gst_caps_new_simple ("video/x-raw", 401 | "width", G_TYPE_INT, width, 402 | "height", G_TYPE_INT, height, 403 | NULL); 404 | 405 | g_object_set (ahc->filter, 406 | "caps", new_caps, 407 | NULL); 408 | 409 | gst_caps_unref (new_caps); 410 | 411 | gst_element_set_state (ahc->pipeline, GST_STATE_PAUSED); 412 | } 413 | 414 | void 415 | gst_native_set_white_balance (JNIEnv * env, jobject thiz, jint wb_mode) 416 | { 417 | GstAhc *ahc = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 418 | 419 | if (!ahc) 420 | return; 421 | 422 | GST_DEBUG ("Setting WB_MODE (%d)", wb_mode); 423 | 424 | g_object_set (ahc->ahcsrc, GST_PHOTOGRAPHY_PROP_WB_MODE, wb_mode, NULL); 425 | } 426 | 427 | void 428 | gst_native_set_auto_focus (JNIEnv * env, jobject thiz, jboolean enabled) 429 | { 430 | GstAhc *ahc = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 431 | 432 | if (!ahc) 433 | return; 434 | 435 | GST_DEBUG ("Setting Autofocus (%d)", enabled); 436 | 437 | gst_photography_set_autofocus (GST_PHOTOGRAPHY (ahc->ahcsrc), enabled); 438 | } 439 | 440 | void 441 | gst_native_set_rotate_method (JNIEnv * env, jobject thiz, jint method) 442 | { 443 | GstAhc *ahc = GET_CUSTOM_DATA (env, thiz, native_android_camera_field_id); 444 | 445 | if (!ahc) 446 | return; 447 | 448 | g_object_set (ahc->vsink, "rotate-method", method, NULL); 449 | } 450 | 451 | static JNINativeMethod native_methods[] = { 452 | {"nativeInit", "()V", (void *) gst_native_init}, 453 | {"nativeFinalize", "()V", (void *) gst_native_finalize}, 454 | {"nativePlay", "()V", (void *) gst_native_play}, 455 | {"nativePause", "()V", (void *) gst_native_pause}, 456 | {"nativeClassInit", "()Z", (void *) gst_class_init}, 457 | {"nativeSurfaceInit", "(Ljava/lang/Object;)V", 458 | (void *) gst_native_surface_init}, 459 | {"nativeSurfaceFinalize", "()V", 460 | (void *) gst_native_surface_finalize}, 461 | {"nativeChangeResolution", "(II)V", 462 | (void *) gst_native_change_resolution}, 463 | {"nativeSetRotateMethod", "(I)V", 464 | (void *) gst_native_set_rotate_method}, 465 | {"nativeSetWhiteBalance", "(I)V", 466 | (void *) gst_native_set_white_balance}, 467 | {"nativeSetAutoFocus", "(Z)V", 468 | (void *) gst_native_set_auto_focus} 469 | }; 470 | 471 | jint 472 | JNI_OnLoad (JavaVM * vm, void *reserved) 473 | { 474 | JNIEnv *env = NULL; 475 | 476 | /* GST_DEBUG can be used to enable gstreamer log on logcat. 477 | * 478 | * setenv ("GST_DEBUG", "*:4,ahc:5,camera-test:5,ahcsrc:5", 1); 479 | * setenv ("GST_DEBUG_NO_COLOR", "1", 1); 480 | */ 481 | 482 | setenv ("GST_DEBUG", "*:4,ahc:5,camera-test:5,ahcsrc:5", 1); 483 | GST_DEBUG_CATEGORY_INIT (debug_category, "camera-test", 0, 484 | "Android Gstreamer Camera test"); 485 | 486 | java_vm = vm; 487 | 488 | if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) { 489 | GST_ERROR ("Could not retrieve JNIEnv"); 490 | return 0; 491 | } 492 | jclass klass = 493 | (*env)->FindClass (env, 494 | "org/freedesktop/gstreamer/camera/GstAhc"); 495 | (*env)->RegisterNatives (env, klass, native_methods, 496 | G_N_ELEMENTS (native_methods)); 497 | 498 | pthread_key_create (¤t_jni_env, detach_current_thread); 499 | 500 | return JNI_VERSION_1_4; 501 | } 502 | -------------------------------------------------------------------------------- /app/src/main/jni/dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/jni/dummy.cpp -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 15 | 16 | 18 | 22 | 23 | 32 | 33 | 38 | 39 | 45 | 46 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/res/layout/autofocus.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/resolution.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 22 | 23 | 32 | 33 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/white_balance.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #66000000 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/photography.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | auto 5 | daylight 6 | cloudy-daylight 7 | twilight 8 | incandescent 9 | fluorescent 10 | manual 11 | warm-fluorescent 12 | shade 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GstAndroidCamera 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.0.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | 20 | # example path usage 21 | # gstAndroidRoot=/Users/justin/Library/Android/gstreamer/1.12.1 22 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 09 11:10:06 CEST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /screenshots/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinjoy/gst-android-camera/e1ea7533a7d61bf32ba48110b0aea0dff0a91b15/screenshots/screenshot.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------