Commit Graph

72 Commits (29e849e3555ff51e38282bae522cbd5706e14aa2)

Author SHA1 Message Date
jp9000 605590606f obs-outputs: Remove send_remaining_packets
Because output stop timing has been fixed, there is no need to send the
remaining packets in the queue because it now just waits for the stop
timing anyway.
2016-06-20 02:56:33 -07:00
jp9000 e77e87007c obs-outputs: Remove unused variable 2016-05-26 09:10:21 -07:00
jp9000 b16557371c obs-outputs: Improve error handling when sending headers
There was no error checking when sending headers/metadata, so what would
happen is that if a header/metadata send failed (meaning the socket was
disconnected), it would continue to act as if it was still connected,
and it would block and lock up on the next send/recv call.
2016-04-26 20:14:31 -07:00
Richard Stanway c42f666b02
obs-outputs: Fix assign instead of compare on socket address type
Detected by Coverity Scan (CID 92187, 92170)
2016-04-13 02:23:23 +02:00
jp9000 2f2cb138bb obs-outputs: Remove trailing/leading whitespace from key/url 2016-03-24 13:42:54 -07:00
jp9000 d510b629c9 obs-outputs: Fix "sometimes uninitialized" warning
Fixes warning (clang):

variable 'added_packet' is used uninitialized whenever 'if' condition is
false [-Wsometimes-uninitialized]
2015-11-18 14:12:54 -08:00
jp9000 f0cf699c50 obs-outputs: Remove stop thread (unnecessary)
Since the RTMP_Close was moved to the send thread (where it should have
been) the stop thread now has no real purpose.
2015-11-18 14:00:28 -08:00
jp9000 f05f0592e0 obs-outputs: Don't allow new data if disconnected 2015-11-18 12:42:14 -08:00
jp9000 6a27da9bd7 obs-outputs: Use atomic load functions 2015-11-18 12:42:14 -08:00
jp9000 ba7b53f330 obs-outputs: Close stream in send thread 2015-11-18 07:49:51 -08:00
jp9000 ee55dafe24 obs-outputs: Atomically update 'active' variable 2015-11-18 07:48:27 -08:00
jp9000 07254d0390 obs-outputs: Call free_packets in init_connect
This may end up being a bit redundant, but it's just to ensure that the
packet buffer is free before connecting.
2015-11-17 07:51:46 -08:00
jp9000 d4df6c191f obs-outputs: Only log packets remaining if above 0 2015-11-17 07:49:05 -08:00
jp9000 226337a6ca obs-outputs: Check for recv error 2015-11-16 13:57:06 -08:00
jp9000 ea69f9cf61 obs-outputs: Call recv when data received
Not calling recv when data is received will accumulate data in the
internal recveive buffer until it's full, in which case is will stop
acknowledging.  This can lead to unjustified disconnections.
2015-11-11 17:45:02 -08:00
jp9000 a6b69a0704 obs-outputs: Log network interface information (win32) 2015-11-11 16:52:48 -08:00
jp9000 b7f64c7482 obs-outputs: Use atomic bool functions 2015-11-03 15:03:40 -08:00
jp9000 40250a62f0 obs-outputs: Remove unnecessary variable
The 'stopping' variable is superfluous due to the fact that 'stop_event'
accomplishes essentially the same exact thing.
2015-11-02 18:36:09 -08:00
jp9000 730132853a obs-outputs: Join with correct thread on destroy
If there was an attempt to destroy the rtmp-stream output while it was
already connecting and stopping at the same time, it would try to join
with the stop thread rather than with the connect thread.  The connect
thread would then continue past destruction.
2015-11-02 15:53:12 -08:00
jp9000 3dab1ebb0a obs-outputs: Send stop signal if no service assigned
The code assumed that the service was valid when that may not be the
case by the time it gets to the code.
2015-11-02 15:52:05 -08:00
jp9000 247c6526cf obs-outputs: Assign names to RTMP threads 2015-11-02 14:52:43 -08:00
jp9000 e350eb5a4c obs-outputs: Stop in thread to prevent locking UI
Sometimes stopping a connection can lock up due to data that still
remains to be sent, and this would lock up the thread requesting the
stop (typically the UI thread).  So instead of locking up the calling
thread, spawn a new thread specifically for stopping so the calling
thread can continue uninterrupted.  If the user attempts to reconnect,
it will wait for the stop thread to complete in the connect thread
before attempting to connect.
2015-11-02 14:50:34 -08:00
jp9000 a0e112ffd9 obs-outputs: Remove unused thread return variable 2015-11-02 14:02:27 -08:00
jp9000 a2a372c141 obs-outputs: Log remaining packets 2015-11-02 13:55:52 -08:00
jp9000 8756115f67 obs-outputs: Have a timeout for backed up packets
If packets get backed up for too long of a time, just disconnect instead
of trying to output them all.
2015-11-01 15:13:37 -08:00
jp9000 071222029b obs-outputs: Stop packet input if disconnected 2015-11-01 14:57:55 -08:00
jp9000 3b48817a7b obs-outputs: Fix race condition
It's possible that packets would still be coming in while the packets
were being freed.
2015-11-01 14:52:49 -08:00
jp9000 c107181b9f obs-outputs: Stop output after joining send thread
The encoders were stopping before processing was completed, which could
cause the output to access data that's potentially invalidated.
2015-09-17 14:17:41 -07:00
jp9000 6285a47726 (API Change) libobs: Pass type data to get_name callbacks
API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

API changed to:
obs_source_info::get_name(void *type_data)
obs_output_info::get_name(void *type_data)
obs_encoder_info::get_name(void *type_data)
obs_service_info::get_name(void *type_data)

This allows the type data to be used when getting the name of the
object (useful for plugin wrappers primarily).

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
2015-09-16 09:21:12 -07:00
jp9000 1ca065b0f2 obs-outputs: Use name and version for encoder
My fault; should have realized that this would be better to do.  Uses
"obs-studio" as the name, and includes the version (same format as the
others)
2015-08-14 17:49:21 -07:00
Marc Chambers db6d9bb042 obs-outputs: Include encoder name in RTMP flashVer
This will help ensure the receiving end knows that OBS is being used.

Closes jp9000/obs-studio#464
2015-08-14 15:58:55 -07:00
Jess Mayo 1682d77df3 obs-outputs: Fix rtmp authentication
Reinstate flag checks in RTMP_Close that were erroneously removed.

Clear out the Link state before we establish a new connection. There is
too much state carried around during authentication that has no good
place to clear it in librtmp, which assumes a clean structure when the
connection is initially established.
2015-07-11 13:53:07 +09:00
Jess Mayo 9f0abd69d1 obs-outputs: Fix crash with quit while connecting
We need to stop the stream even if it hasn't finished opening yet,
to make sure threads are cleaned up properly.
2015-07-08 13:12:47 +09:00
jp9000 63b3cfb5b2 obs-outputs: Reset frame drop variables on start
These variables should be reset when a stream is restarted.
2015-04-18 00:47:00 -07:00
jp9000 0e2a5d2de2 obs-outputs: Do not drop I-frames
When frames were dropped, it would also drop I-frames, which can mess
with the keyframe calculation of certain services that depend on
I-frames in their output protocol (such as HLS).
2015-04-10 07:27:27 -07:00
jp9000 56f4dd5359 obs-outputs: Fix bug (headers not always sent)
If a disconnection occurs, the sent_headers would still be set to true,
and when a reconnect occurs, it would not send the headers again.
2015-03-07 10:11:18 -08:00
jp9000 e1acd93002 obs-outputs: Remove trailing whitespace 2015-02-04 16:51:56 -08:00
jp9000 7c5034d58f obs-outputs: Add support for multi-track RTMP
Certain RTMP services will support multi audio tracks via RTMP.  This
updates librtmp with custom code that enables multiple streams per
connection to be used; each subsequent stream typically containing extra
audio tracks.  The audio encoder names are used to indicate the names of
tracks, and the name of the tracks are used for the stream keys for
those subsequent tracks.
2015-02-04 16:51:56 -08:00
jp9000 84e1f47ced (API Change) Add support for multiple audio mixers
API changed:
--------------------------

void obs_output_set_audio_encoder(
		obs_output_t *output,
		obs_encoder_t *encoder);

obs_encoder_t *obs_output_get_audio_encoder(
		const obs_output_t *output);

obs_encoder_t *obs_audio_encoder_create(
		const char *id,
		const char *name,
		obs_data_t *settings);

Changed to:
--------------------------

/* 'idx' specifies the track index of the output */
void obs_output_set_audio_encoder(
		obs_output_t *output,
		obs_encoder_t *encoder,
		size_t idx);

/* 'idx' specifies the track index of the output */
obs_encoder_t *obs_output_get_audio_encoder(
		const obs_output_t *output,
		size_t idx);

/* 'mixer_idx' specifies the mixer index to capture audio from */
obs_encoder_t *obs_audio_encoder_create(
		const char *id,
		const char *name,
		obs_data_t *settings,
		size_t mixer_idx);

Overview
--------------------------
This feature allows multiple audio mixers to be used at a time.  This
capability was able to be added with surprisingly very little extra
overhead.  Audio will not be mixed unless it's assigned to a specific
mixer, and mixers will not mix unless they have an active mix
connection.

Mostly this will be useful for being able to separate out specific audio
for recording versus streaming, but will also be useful for certain
streaming services that support multiple audio streams via RTMP.

I didn't want to use a variable amount of mixers due to the desire to
reduce heap allocations, so currently I set the limit to 4 simultaneous
mixers; this number can be increased later if needed, but honestly I
feel like it's just the right number to use.

Sources:

Sources can now specify which audio mixers their audio is mixed to; this
can be a single mixer or multiple mixers at a time.  The
obs_source_set_audio_mixers function sets the audio mixer which an audio
source applies to.  For example, 0xF would mean that the source applies
to all four mixers.

Audio Encoders:

Audio encoders now must specify which specific audio mixer they use when
they encode audio data.

Outputs:

Outputs that use encoders can now support multiple audio tracks at once
if they have the OBS_OUTPUT_MULTI_TRACK capability flag set.  This is
mostly only useful for certain types of RTMP transmissions, though may
be useful for file formats that support multiple audio tracks as well
later on.
2015-02-04 16:51:29 -08:00
jp9000 3412a0e190 obs-outputs: Wait for packet before header output
Waiting for the first packet to arrive before sending the headers helps
prevent issues with certain types of encoders that may not get their
header/SEI until the first packet has been received.
2014-12-21 10:14:23 -08:00
Lexsus 9c34be8af1 obs-outputs: Allow blank RTMP stream key usage
Allows a blank stream key to be used for RTMP streams.
2014-11-18 03:45:49 -08:00
Palana 94a93abb2b (API Change) Pass data to get_properties when possible 2014-10-01 15:39:57 +02:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000 9d300685ca (API Change) Unsquish libobs/util
Changed:                      To:
-----------------------------------------------------------
dstr_isempty                  dstr_is_empty
cf_lexer_gettokens            cf_lexer_get_tokens
cf_preprocessor_gettokens     cf_preprocessor_get_tokens
2014-08-09 11:57:37 -07:00
jp9000 04712b5fe9 (API Change) Unsquish obs_data_* names
Changed:                 To:
-----------------------------------------------
obs_data_getjson         obs_data_get_json
obs_data_getstring       obs_data_get_string
obs_data_getint          obs_data_get_int
obs_data_getdouble       obs_data_get_double
obs_data_getbool         obs_data_get_bool
obs_data_getobj          obs_data_get_obj
obs_data_getarray        obs_data_get_array
obs_data_setstring       obs_data_set_string
obs_data_setint          obs_data_set_int
obs_data_setdouble       obs_data_set_double
obs_data_setbool         obs_data_set_bool
obs_data_setobj          obs_data_set_obj
obs_data_setarray        obs_data_set_array
obs_data_item_getstring  obs_data_item_get_string
obs_data_item_getint     obs_data_item_get_int
obs_data_item_getdouble  obs_data_item_get_double
obs_data_item_getbool    obs_data_item_get_bool
obs_data_item_getobj     obs_data_item_get_obj
obs_data_item_getarray   obs_data_item_get_array
obs_data_item_setstring  obs_data_item_set_string
obs_data_item_setint     obs_data_item_set_int
obs_data_item_setdouble  obs_data_item_set_double
obs_data_item_setbool    obs_data_item_set_bool
obs_data_item_setobj     obs_data_item_set_obj
obs_data_item_setarray   obs_data_item_set_array
2014-08-09 11:57:36 -07:00
jp9000 2d606dd8d8 (API Change) Use 'get' convention: API callbacks
Renamed:                       To:
-------------------------------------------------------
obs_source_info::defaults       obs_source_info::get_defaults
obs_source_info::properties     obs_source_info::get_properties
obs_output_info::defaults       obs_output_info::get_defaults
obs_output_info::properties     obs_output_info::get_properties
obs_output_info::total_bytes    obs_output_info::get_total_bytes
obs_output_info::dropped_frames obs_output_info::get_dropped_frames
obs_encoder_info::defaults      obs_encoder_info::get_defaults
obs_encoder_info::properties    obs_encoder_info::get_properties
obs_encoder_info::extra_data    obs_encoder_info::get_extra_data
obs_encoder_info::sei_data      obs_encoder_info::get_sei_data
obs_encoder_info::audio_info    obs_encoder_info::get_audio_info
obs_encoder_info::video_info    obs_encoder_info::get_video_fino
obs_service_info::defaults      obs_service_info::get_defaults
obs_service_info::properties    obs_service_info::get_properties
2014-08-09 11:57:30 -07:00
jp9000 c83d05117f (API Change) Unsquish libobs API callback names
Renamed:                    To:
-------------------------------------------------------
obs_source_info::getname    obs_source_info::get_name
obs_source_info::getwidth   obs_source_info::get_width
obs_source_info::getheight  obs_source_info::get_height
obs_output_info::getname    obs_output_info::get_name
obs_encoder_info::getname   obs_encoder_info::get_name
obs_service_info::getname   obs_service_info::get_name
2014-08-08 11:04:46 -07:00
jp9000 73baaa59e9 (API Change) Unsquish libobs (base) names
Previous names:             New names:
-----------------------------------------------------------
obs_view_setsource          obs_view_set_source
obs_view_getsource          obs_view_get_source
obs_source_getdisplayname   obs_source_get_display_name
obs_source_getwidth         obs_source_get_width
obs_source_getheight        obs_source_get_height
obs_filter_getparent        obs_filter_get_parent
obs_filter_gettarget        obs_filter_get_target
obs_source_filter_setorder  obs_source_filter_set_order
obs_source_getsettings      obs_source_get_settings
obs_source_getname          obs_source_get_name
obs_source_setname          obs_source_set_name
obs_source_setvolume        obs_source_set_volume
obs_source_getvolume        obs_source_get_volume
obs_scene_getsource         obs_scene_get_source
obs_scene_fromsource        obs_scene_from_source
obs_scene_findsource        obs_scene_find_source
obs_output_getdisplayname   obs_output_get_display_name
obs_output_getname          obs_output_get_name
obs_encoder_getname         obs_encoder_get_name
obs_service_getdisplayname  obs_service_get_display_name
obs_service_getname         obs_service_get_name
2014-08-08 11:04:46 -07:00
jp9000 482791c5b6 Add locale for modules 2014-07-11 17:29:00 -07:00
jp9000 0364672cbb rtmp-stream: Add statistics callbacks
Add callbacks for total bytes sent and number of dropped frames
2014-07-06 17:36:45 -07:00