Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2014-2015 Jolla Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. * Authored by: Mohammed Hassan <mohammed.hassan@jolla.com>
  17. */
  18.  
  19. #include "droidmediaconvert.h"
  20. #include "droidmediabuffer.h"
  21. #include <media/editor/II420ColorConverter.h>
  22. #include <media/openmax/OMX_IVCommon.h>
  23. #include <cutils/log.h>
  24. #include <dlfcn.h>
  25.  
  26. typedef void (*_getI420ColorConverter)(II420ColorConverter *converter);
  27.  
  28. #define LOG_TAG "DroidMediaConvert"
  29.  
  30. extern "C" {
  31.  
  32. struct _DroidMediaConvert : public II420ColorConverter
  33. {
  34. public:
  35. _DroidMediaConvert() :
  36. m_handle(NULL) {
  37. ALOGE("%s", __func__);
  38. m_crop.top = m_crop.left = m_crop.bottom = m_crop.right = -1;
  39. m_width = m_height = 0;
  40. }
  41.  
  42. ~_DroidMediaConvert() {
  43. ALOGE("%s", __func__);
  44. if (m_handle) {
  45. dlclose(m_handle);
  46. m_handle = NULL;
  47. }
  48. }
  49.  
  50. bool init() {
  51. ALOGE("%s", __func__);
  52. if (m_handle) {
  53. ALOGW("already loaded");
  54. return true;
  55. }
  56.  
  57. m_handle = dlopen("libI420colorconvert.so", RTLD_NOW);
  58. if (!m_handle) {
  59. ALOGE("failed to load libI420colorconvert.so. %s", dlerror());
  60. return false;
  61. }
  62.  
  63. _getI420ColorConverter func = (_getI420ColorConverter)dlsym(m_handle, "getI420ColorConverter");
  64. if (!func) {
  65. ALOGE("failed to find symbol getI420ColorConverter");
  66. dlclose(m_handle);
  67. m_handle = NULL;
  68. return false;
  69. }
  70.  
  71. func(this);
  72.  
  73. return true;
  74. }
  75.  
  76. void *m_handle;
  77. ARect m_crop;
  78. int32_t m_width;
  79. int32_t m_height;
  80. };
  81.  
  82. DroidMediaConvert *droid_media_convert_create()
  83. {
  84. ALOGE("a%s", __func__);
  85. DroidMediaConvert *conv = new DroidMediaConvert;
  86. if (conv->init()) {
  87. return conv;
  88. }
  89.  
  90. delete conv;
  91. return NULL;
  92. }
  93.  
  94. DroidMediaConvert *convert;
  95.  
  96. int main(int argc, char *argv[])
  97. {
  98. convert = droid_media_convert_create();
  99. delete convert;
  100.  
  101. return 0;
  102. }
  103.  
  104. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement