소스 검색

Updated comments for outputs/encoders

Changed the comments to properly reflect the new callbacks, as I had
forgotten to update the comments for them both.

Also, changed "setbitrate" and "request_keyframe" return values to be
boolean.
jp9000 11 년 전
부모
커밋
ff1afac5f8
5개의 변경된 파일66개의 추가작업 그리고 80개의 파일을 삭제
  1. 6 4
      libobs/obs-encoder.c
  2. 53 39
      libobs/obs-encoder.h
  3. 2 2
      libobs/obs-output.c
  4. 3 33
      libobs/obs-output.h
  5. 2 2
      libobs/obs.h

+ 6 - 4
libobs/obs-encoder.c

@@ -139,18 +139,20 @@ int obs_encoder_getheader(obs_encoder_t encoder,
 	return encoder->callbacks.getheader(encoder, packets);
 }
 
-void obs_encoder_setbitrate(obs_encoder_t encoder, uint32_t bitrate,
+bool obs_encoder_setbitrate(obs_encoder_t encoder, uint32_t bitrate,
 		uint32_t buffersize)
 {
 	if (encoder->callbacks.setbitrate)
-		encoder->callbacks.setbitrate(encoder->data, bitrate,
+		return encoder->callbacks.setbitrate(encoder->data, bitrate,
 				buffersize);
+	return false;
 }
 
-void obs_encoder_request_keyframe(obs_encoder_t encoder)
+bool obs_encoder_request_keyframe(obs_encoder_t encoder)
 {
 	if (encoder->callbacks.request_keyframe)
-		encoder->callbacks.request_keyframe(encoder->data);
+		return encoder->callbacks.request_keyframe(encoder->data);
+	return false;
 }
 
 const char *obs_encoder_get_settings(obs_encoder_t encoder)

+ 53 - 39
libobs/obs-encoder.h

@@ -22,87 +22,101 @@
 
 /*
  * ===========================================
- *  Outputs 
+ *  Encoders 
  * ===========================================
  *
- *   An output takes raw audio and/or video and processes and/or outputs it
- * to a destination, whether that destination be a file, network, or other.
+ *   An encoder context allows data to be encoded from raw output, and allow
+ * it to be used to output contexts (such as outputting to stream).
  *
- *   A module with outputs needs to export these functions:
- *       + enum_outputs
+ *   A module with encoders needs to export these functions:
+ *       + enum_encoders
  *
- *   Each individual output is then exported by it's name.  For example, an
- * output named "myoutput" would have the following exports:
- *       + myoutput_getname
- *       + myoutput_create
- *       + myoutput_destroy
- *       + myoutput_start
- *       + myoutput_stop
- *       + myoutput_encoders
+ *   Each individual encoder is then exported by it's name.  For example, an
+ * encoder named "myencoder" would have the following exports:
+ *       + myencoder_getname
+ *       + myencoder_create
+ *       + myencoder_destroy
+ *       + myencoder_update
+ *       + myencoder_reset
+ *       + myencoder_encode
+ *       + myencoder_getheader
  *
  *       [and optionally]
- *       + myoutput_setencoder
- *       + myoutput_getencoder
- *       + myoutput_config
- *       + myoutput_pause
+ *       + myencoder_setbitrate
+ *       + myencoder_request_keyframe
  *
  * ===========================================
  *   Primary Exports
  * ===========================================
- *   const char *enum_outputs(size_t idx);
- *       idx: index of the output.
- *       Return value: Output identifier name.  NULL when no more available.
+ *   const char *enum_encoders(size_t idx);
+ *       idx: index of the encoder.
+ *       Return value: Encoder identifier name.  NULL when no more available.
  *
  * ===========================================
- *   Output Exports
+ *   Encoder Exports
  * ===========================================
  *   const char *[name]_getname(const char *locale);
- *       Returns the full translated name of the output type (seen by the user).
+ *       Returns the full translated name of the encoder type
+ *       (seen by the user).
  *
  * ---------------------------------------------------------
- *   void *[name]_create(const char *settings, obs_output_t output);
- *       Creates an output.
+ *   void *[name]_create(const char *settings, const char *name,
+ *                       obs_encoder_t encoder);
+ *       Creates an encoder.
  *
- *       settings: Settings of the output.
- *       output: pointer to main output
- *       Return value: Internal output pointer, or NULL if failed.
+ *       settings: Settings of the encoder.
+ *       name: Name of the encoder.
+ *       encoder: Pointer to encoder context.
+ *       Return value: Internal encoder pointer, or NULL if failed.
  *
  * ---------------------------------------------------------
  *   void [name]_destroy(void *data);
- *       Destroys the output.
+ *       Destroys the encoder.
  *
  * ---------------------------------------------------------
  *   void [name]_update(void *data, const char *settings)
- *       Updates the output's settings
+ *       Updates the encoder's settings
  *
- *       settings: New settings of the output
+ *       settings: New settings of the encoder
  *
  * ---------------------------------------------------------
  *   bool [name]_reset(void *data)
- *       Starts output
+ *       Restarts encoder
  *
  *       Return value: true if successful
  *
  * ---------------------------------------------------------
  *   int [name]_encode(void *data, void *frames, size_t size,
  *                      struct encoder_packet **packets)
+ *       Encodes data.
  *
  *       frames: frame data
  *       size: size of data pointed to by the frame parameter
  *       packets: returned packets, or NULL if none
- *       Return value: number of output frames
+ *       Return value: number of encoder frames
  *
  * ---------------------------------------------------------
- *   bool [name]_reset(void *data)
- *       Resets encoder data
+ *   int [name]_getheader(void *data, struct encoder_packet **packets)
+ *       Returns the header packets for this encoder.
  *
- *       Return value: true if successful
+ *       packets: returned packets, or NULL if none
+ *       Return value: number of encoder frames
  *
  * ===========================================
- *   Optional Output Exports
+ *   Optional Encoder Exports
  * ===========================================
- *   void [name]_setbitrate(void *data, uint32_t bitrate, uint32_t buffersize);
+ *   bool [name]_setbitrate(void *data, uint32_t bitrate, uint32_t buffersize);
  *       Sets the bitrate of the encoder
+ *
+ *       bitrate: Bitrate
+ *       buffersize: Buffer size
+ *       Returns true if successful/compatible
+ *
+ * ---------------------------------------------------------
+ *   bool [name]_request_keyframe(void *data)
+ *       Requests a keyframe from the encoder
+ *
+ *       Returns true if successful/compatible.
  */
 
 struct obs_encoder;
@@ -124,8 +138,8 @@ struct encoder_info {
 	int (*getheader)(void *data, struct encoder_packet **packets);
 
 	/* optional */
-	void (*setbitrate)(void *data, uint32_t bitrate, uint32_t buffersize);
-	void (*request_keyframe)(void *data);
+	bool (*setbitrate)(void *data, uint32_t bitrate, uint32_t buffersize);
+	bool (*request_keyframe)(void *data);
 };
 
 struct obs_encoder_callback {

+ 2 - 2
libobs/obs-output.c

@@ -27,6 +27,8 @@ bool load_output_info(void *module, const char *module_name,
 			output_id, "create", true);
 	info->destroy = load_module_subfunc(module, module_name,
 			output_id, "destroy", true);
+	info->update = load_module_subfunc(module, module_name,
+			output_id, "update", true);
 	info->start = load_module_subfunc(module, module_name,
 			output_id, "start", true);
 	info->stop = load_module_subfunc(module, module_name,
@@ -38,8 +40,6 @@ bool load_output_info(void *module, const char *module_name,
 	    !info->start || !info->stop || !info->active)
 		return false;
 
-	info->update = load_module_subfunc(module, module_name,
-			output_id, "update", false);
 	info->pause = load_module_subfunc(module, module_name,
 			output_id, "pause", false);
 

+ 3 - 33
libobs/obs-output.h

@@ -36,12 +36,11 @@
  *       + myoutput_getname
  *       + myoutput_create
  *       + myoutput_destroy
+ *       + myoutput_update
  *       + myoutput_start
  *       + myoutput_stop
- *       + myoutput_encoders
  *
  *       [and optionally]
- *       + myoutput_config
  *       + myoutput_pause
  *
  * ===========================================
@@ -89,39 +88,9 @@
  *   bool [name]_active(void *data)
  *       Returns whether currently active or not
  *
- * ---------------------------------------------------------
- *   uint32_t [name]_encoders(void *data)
- *       Returns 0 or a combination of the following values:
- *           + OUTPUT_VIDEO_ENCODER: requires a video encoder
- *           + OUTPUT_AUDIO_ENCODER: requires an audio encoder
- *
  * ===========================================
  *   Optional Output Exports
  * ===========================================
- *   bool [name]_setencoder(void *data, obs_encoder_t encoder,
- *                          enum obs_encoder_type type)
- *       Sets the encoder for this output.
- *
- *       encoder: Encoder context
- *       type: Type of encoder (ENCODER_VIDEO or ENCODER_AUDIO)
- *
- *       Returns true if successful and compatible
- *
- * ---------------------------------------------------------
- *   obs_encoder_t [name]_getencoder(void *data, enum obs_encoder_type type)
- *       Gets the encoder for this output
- *
- *       type: Type of encoder
- *
- *       Returns the encoder, or NULL if none.
- *
- * ---------------------------------------------------------
- *   void [name]_config(void *data, void *parent);
- *       Called to configure the output.
- *
- *       parent: Parent window pointer
- *
- * ---------------------------------------------------------
  *   void [name]_pause(void *data)
  *       Pauses output.  Typically only usable for local recordings.
  */
@@ -136,13 +105,14 @@ struct output_info {
 	void *(*create)(const char *settings, struct obs_output *output);
 	void (*destroy)(void *data);
 
+	void (*update)(void *data, const char *settings);
+
 	bool (*start)(void *data);
 	void (*stop)(void *data);
 
 	bool (*active)(void *data);
 
 	/* optional */
-	void (*update)(void *data, const char *settings);
 	void (*pause)(void *data);
 };
 

+ 2 - 2
libobs/obs.h

@@ -599,10 +599,10 @@ EXPORT bool obs_encoder_stop(obs_encoder_t encoder,
 		void (*new_packet)(void *param, struct encoder_packet *packet),
 		void *param);
 
-EXPORT void obs_encoder_setbitrate(obs_encoder_t encoder, uint32_t bitrate,
+EXPORT bool obs_encoder_setbitrate(obs_encoder_t encoder, uint32_t bitrate,
 		uint32_t buffersize);
 
-EXPORT void obs_encoder_request_keyframe(obs_encoder_t encoder);
+EXPORT bool obs_encoder_request_keyframe(obs_encoder_t encoder);
 
 EXPORT const char *obs_encoder_get_settings(obs_encoder_t encoder);