MobileFFmpeg.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (c) 2018 Taner Sener
  3. *
  4. * This file is part of MobileFFmpeg.
  5. *
  6. * MobileFFmpeg is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * MobileFFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <string.h>
  20. #include <stdlib.h>
  21. #include <Foundation/Foundation.h>
  22. #include "ExecuteDelegate.h"
  23. /** Global library version */
  24. extern NSString *const MOBILE_FFMPEG_VERSION;
  25. /**
  26. * Main class for FFmpeg operations.
  27. */
  28. @interface MobileFFmpeg : NSObject
  29. /**
  30. * Synchronously executes FFmpeg with arguments provided.
  31. *
  32. * @param arguments FFmpeg command options/arguments as string array
  33. * @return zero on successful execution, 255 on user cancel and non-zero on error
  34. */
  35. + (int)executeWithArguments:(NSArray*)arguments;
  36. /**
  37. * Asynchronously executes FFmpeg with arguments provided. Space character is used to split command into arguments.
  38. *
  39. * @param arguments FFmpeg command options/arguments as string array
  40. * @param delegate delegate that will be notified when execution is completed
  41. * @return returns a unique id that represents this execution
  42. */
  43. + (int)executeWithArgumentsAsync:(NSArray*)arguments withCallback:(id<ExecuteDelegate>)delegate;
  44. /**
  45. * Asynchronously executes FFmpeg with arguments provided. Space character is used to split command into arguments.
  46. *
  47. * @param arguments FFmpeg command options/arguments as string array
  48. * @param delegate delegate that will be notified when execution is completed
  49. * @param queue dispatch queue that will be used to run this asynchronous operation
  50. * @return returns a unique id that represents this execution
  51. */
  52. + (int)executeWithArgumentsAsync:(NSArray*)arguments withCallback:(id<ExecuteDelegate>)delegate andDispatchQueue:(dispatch_queue_t)queue;
  53. /**
  54. * Synchronously executes FFmpeg command provided. Space character is used to split command into arguments.
  55. *
  56. * @param command FFmpeg command
  57. * @return zero on successful execution, 255 on user cancel and non-zero on error
  58. */
  59. + (int)execute:(NSString*)command;
  60. /**
  61. * Asynchronously executes FFmpeg command provided. Space character is used to split command into arguments.
  62. *
  63. * @param command FFmpeg command
  64. * @param delegate delegate that will be notified when execution is completed
  65. * @return returns a unique id that represents this execution
  66. */
  67. + (int)executeAsync:(NSString*)command withCallback:(id<ExecuteDelegate>)delegate;
  68. /**
  69. * Asynchronously executes FFmpeg command provided. Space character is used to split command into arguments.
  70. *
  71. * @param command FFmpeg command
  72. * @param delegate delegate that will be notified when execution is completed
  73. * @param queue dispatch queue that will be used to run this asynchronous operation
  74. * @return returns a unique id that represents this execution
  75. */
  76. + (int)executeAsync:(NSString*)command withCallback:(id<ExecuteDelegate>)delegate andDispatchQueue:(dispatch_queue_t)queue;
  77. /**
  78. * Synchronously executes FFmpeg command provided. Delimiter parameter is used to split command into arguments.
  79. *
  80. * @param command FFmpeg command
  81. * @param delimiter arguments delimiter
  82. * @deprecated argument splitting mechanism used in this method is pretty simple and prone to errors. Consider
  83. * using a more advanced method like execute or executeWithArguments
  84. * @return zero on successful execution, 255 on user cancel and non-zero on error
  85. */
  86. + (int)execute:(NSString*)command delimiter:(NSString*)delimiter __attribute__((deprecated));
  87. /**
  88. * Cancels an ongoing operation.
  89. *
  90. * This function does not wait for termination to complete and returns immediately.
  91. */
  92. + (void)cancel;
  93. /**
  94. * Cancels an ongoing operation.
  95. *
  96. * This function does not wait for termination to complete and returns immediately.
  97. *
  98. * @param executionId execution id
  99. */
  100. + (void)cancel:(long)executionId;
  101. /**
  102. * Parses the given command into arguments.
  103. *
  104. * @param command string command
  105. * @return array of arguments
  106. */
  107. + (NSArray*)parseArguments:(NSString*)command;
  108. /**
  109. * <p>Combines arguments into a string.
  110. *
  111. * @param arguments arguments
  112. * @return string containing all arguments
  113. */
  114. + (NSString*)argumentsToString:(NSArray*)arguments;
  115. /**
  116. * <p>Lists ongoing executions.
  117. *
  118. * @return list of ongoing executions
  119. */
  120. + (NSArray*)listExecutions;
  121. @end