~ubuntu-branches/ubuntu/utopic/gst-plugins-bad1.0/utopic

« back to all changes in this revision

Viewing changes to sys/androidmedia/gstamchybris.c

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-10-13 00:30:29 UTC
  • Revision ID: package-import@ubuntu.com-20131013003029-e948f02g1aq3go50
Tags: 1.2.0-3ubuntu3
* Refreshing adding-mirsink-and-android-media-over-hybris-support.patch:
  - Adding support for software rendering
  - Better input/out buffer handling
* debian/build-deps.in:
  - Bumping dep version requirement for libmedia

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
static gboolean accepted_color_formats (GstAmcCodecType * type,
58
58
    gboolean is_encoder);
59
59
 
 
60
/* FIXME: enable support for platform-api again once it's stable enough
 
61
 * when using it with MIR (currently it creates all sorts of crashes */
 
62
#if 0
60
63
static struct ua_display *
61
64
create_display (void)
62
65
{
63
66
  struct ua_display *display;
64
 
  display = malloc (sizeof *display);
 
67
  display = malloc (sizeof (struct ua_display));
65
68
 
66
69
  display->display = ua_ui_display_new_with_index (0);
67
70
  if (display->display == NULL) {
82
85
{
83
86
  struct ua_session *session;
84
87
  char argv[1][1];
85
 
  session = malloc (sizeof *session);
 
88
  session = malloc (sizeof (struct ua_session));
86
89
 
87
90
  session->properties = ua_ui_session_properties_new ();
88
91
  ua_ui_session_properties_set_type (session->properties, U_USER_SESSION);
90
93
  if (!session->session)
91
94
    GST_WARNING ("Failed to start new Ubuntu Application API session");
92
95
 
 
96
  /* The UA requires a command line option set, so give it a fake argv array */
 
97
  argv[0][0] = '\0';
 
98
  session->app_options =
 
99
      u_application_options_new_from_cmd_line (1, (char **) argv);
 
100
 
93
101
  session->app_description = u_application_description_new ();
 
102
 
 
103
  /* Required by Mir */
 
104
  session->app_id = u_application_id_new_from_stringn ("gstamc", 6);
 
105
  u_application_description_set_application_id (session->app_description,
 
106
      session->app_id);
 
107
 
94
108
  session->app_lifecycle_delegate = u_application_lifecycle_delegate_new ();
95
109
  /* No context data to pass to the lifecycle delegate for now */
96
110
  u_application_lifecycle_delegate_set_context
98
112
  u_application_description_set_application_lifecycle_delegate
99
113
      (session->app_description, session->app_lifecycle_delegate);
100
114
 
101
 
  /* The UA requires a command line option set, so give it a fake argv array */
102
 
  argv[0][0] = '\n';
103
 
  session->app_options =
104
 
      u_application_options_new_from_cmd_line (1, (char **) argv);
105
115
  session->app_instance =
106
116
      u_application_instance_new_from_description_with_options
107
117
      (session->app_description, session->app_options);
120
130
  g_return_val_if_fail (display != NULL, NULL);
121
131
  g_return_val_if_fail (session != NULL, NULL);
122
132
 
123
 
  window = malloc (sizeof *window);
 
133
  window = malloc (sizeof (struct ua_window));
124
134
  window->display = display;
125
135
  window->width = width;
126
136
  window->height = height;
164
174
    u_application_options_destroy (session->app_options);
165
175
 */
166
176
 
 
177
  if (session->app_id)
 
178
    u_application_id_destroy (session->app_id);
 
179
 
167
180
  if (session->app_description)
168
181
    u_application_description_destroy (session->app_description);
169
182
 
182
195
 
183
196
  free (window);
184
197
}
 
198
#endif
185
199
 
186
200
static gchar *
187
201
locale_to_utf8 (gchar * str, gssize len)
241
255
gst_amc_codec_free (GstAmcCodec * codec)
242
256
{
243
257
  g_return_if_fail (codec != NULL);
 
258
  g_return_if_fail (codec->codec_delegate != NULL);
244
259
 
245
260
  GST_DEBUG ("%s", __PRETTY_FUNCTION__);
246
261
 
 
262
  // Cleanup the hardware decoder's resources
247
263
  media_codec_delegate_unref (codec->codec_delegate);
248
 
  media_codec_delegate_destroy (codec->codec_delegate);
249
264
 
250
265
  g_slice_free (GstAmcCodec, codec);
251
266
}
262
277
  g_return_val_if_fail (codec != NULL, FALSE);
263
278
  g_return_val_if_fail (format != NULL, FALSE);
264
279
 
 
280
  /* FIXME: find a better way to sink the texture_id from mirsink */
 
281
  if (!surface_texture_client_is_ready_for_rendering ()) {
 
282
    GST_WARNING
 
283
        ("Surface texture client is not yet ready, waiting a bit for the texture id");\
 
284
    g_usleep(G_USEC_PER_SEC / 10);
 
285
  }
 
286
 
265
287
  GST_WARNING ("surface_texture_client_is_ready_for_rendering: %d",
266
288
      surface_texture_client_is_ready_for_rendering ());
 
289
 
267
290
  if (!surface_texture_client_is_ready_for_rendering ()) {
268
291
    GST_WARNING
269
292
        ("SurfaceTextureClientHybris is not ready for rendering, creating EGLNativeWindowType");
 
293
 
 
294
    /* Do slower copy-based software rendering */
 
295
    gst_amc_surface_texture_client_set_hardware_rendering (FALSE);
 
296
 
 
297
#if 0
270
298
    /* Create a new Ubuntu Application API session */
271
299
    codec->session = create_session ();
272
300
 
290
318
        create_window (codec->display, codec->session, codec->display->width,
291
319
        codec->display->height);
292
320
    surface_texture_client_create (codec->window->egl_native_window);
 
321
#endif
 
322
  } else {
 
323
    /* Do zero-copy hardware rendering */
 
324
    gst_amc_surface_texture_client_set_hardware_rendering (TRUE);
293
325
  }
294
326
 
295
327
  err = media_codec_configure (codec->codec_delegate, format->format, stc, 0);
388
420
    goto done;
389
421
  }
390
422
 
 
423
#if 0
391
424
  if (codec->window)
392
425
    destroy_window (codec->window);
393
426
  if (codec->display)
394
427
    destroy_display (codec->display);
395
428
  if (codec->session)
396
429
    destroy_session (codec->session);
 
430
#endif
397
431
 
398
432
done:
399
433
 
649
683
}
650
684
 
651
685
gboolean
652
 
gst_amc_codec_release_output_buffer (GstAmcCodec * codec, gint index)
 
686
gst_amc_codec_release_output_buffer (GstAmcCodec * codec, gint index,
 
687
    gboolean render)
653
688
{
654
689
  gboolean ret = TRUE;
655
690
  gint err = 0;
658
693
 
659
694
  GST_DEBUG ("%s", __PRETTY_FUNCTION__);
660
695
 
661
 
  err = media_codec_release_output_buffer (codec->codec_delegate, index);
 
696
  err =
 
697
      media_codec_release_output_buffer (codec->codec_delegate, index, render);
662
698
  if (err < 0) {
663
699
    GST_ERROR ("Failed to release output buffer (err: %d, index: %d)", err,
664
700
        index);
857
893
  key_str = NULL;
858
894
}
859
895
 
 
896
void
 
897
gst_amc_surface_texture_client_set_hardware_rendering (gboolean
 
898
    hardware_rendering)
 
899
{
 
900
  surface_texture_client_set_hardware_rendering (hardware_rendering);
 
901
}
 
902
 
860
903
static gboolean
861
904
scan_codecs (GstPlugin * plugin)
862
905
{