media-io.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. /*
  16. * Media input/output components used for connecting media outputs/inputs
  17. * together. An input requests a connection to an output and the output
  18. * sends frames to it through the callbacks in media_data_in structure.
  19. *
  20. * The id member should indicate the format/parameters used in text form.
  21. */
  22. /* opaque data types */
  23. struct media_input;
  24. struct media_output;
  25. struct media_data;
  26. typedef struct media_input *media_input_t;
  27. typedef struct media_output *media_output_t;
  28. typedef struct media_data *media_t;
  29. #include "../util/c99defs.h"
  30. #include "video-io.h"
  31. #include "audio-io.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. struct media_input_info {
  36. const char *format;
  37. void *obj;
  38. void (*on_input)(void *obj, const void *data);
  39. };
  40. struct media_output_info {
  41. const char *format;
  42. void *obj;
  43. bool (*connect)(void *obj, media_input_t input);
  44. };
  45. EXPORT media_input_t media_input_create(struct media_input_info *info);
  46. EXPORT void media_input_destroy(media_input_t input);
  47. EXPORT media_output_t media_output_create(struct media_output_info *info);
  48. EXPORT void media_output_data(media_output_t out, const void *data);
  49. EXPORT void media_output_destroy(media_output_t output);
  50. EXPORT media_t media_open(void);
  51. EXPORT bool media_add_input(media_t media, media_input_t input);
  52. EXPORT void media_add_output(media_t media, media_output_t output);
  53. EXPORT void media_remove_input(media_t media, media_input_t input);
  54. EXPORT void media_remove_output(media_t media, media_output_t output);
  55. EXPORT void media_close(media_t media);
  56. #ifdef __cplusplus
  57. }
  58. #endif