0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 21:13:04 +02:00
Commit Graph

754 Commits

Author SHA1 Message Date
fryshorts
9a14661507 Add option to use alternative timestamps
With this option enabled the plugin will generate timestamps
based on the system time instead of using the ones provided by
pulse audio. This might fix problems with audio desync and may
become the default/only option in the future.
2014-04-28 22:00:04 +02:00
fryshorts
30a688e942 Implement defaults functions
The defaults functions will now return the default device for the
input/output as provided by pulseaudio.
The default output device is the monitor of the default sink.
2014-04-28 22:00:04 +02:00
fryshorts
bbda252e2d Add support for changing the audio device while recording
Changing the audio device in the source properties will now cause
the plugin to switch recording to the new device.
2014-04-28 22:00:04 +02:00
Jim
160b44e417 Merge pull request #71 from fryshorts/master
Some minor fixes
2014-04-26 12:57:20 -07:00
jp9000
6347416434 obs-x264: Woops, forgot to remove .rc 2014-04-26 11:39:28 -07:00
jp9000
1a0bfe3244 obs-x264: Use regular CBR if x264 version < 139
Some linux packages on linux are way too old.  Very annoying.
2014-04-26 11:30:04 -07:00
fryshorts
48391beacd Close rtmp connection when stream is stopped.
This will close the connection to the server when the stream
is stopped.
2014-04-26 02:04:37 +02:00
jp9000
89e02ca73c obs-outputs: Log connections/disconnections 2014-04-24 21:11:46 -07:00
fryshorts
1ee4496dae Added a wrapping library for pulseaudio
The wrapping library uses a global mainloop and context which
allows operations to share the connection. The global mainloop
is created and destroyed based on internal reference counting.

The capture code won't spawn a new thread for each input anymore
but instead just create the recording stream and rely on the
threaded mainloop to execute the read callback when data is available.
2014-04-24 23:51:13 +02:00
Palana
07ab8271b6 Remove setsockopt for SIGPIPE; disable SIGPIPE via signal() on non-WIN32 2014-04-24 23:50:40 +02:00
Palana
138bf4cc1e Disable SIGPIPE for RTMP socket in librtmp 2014-04-24 23:28:12 +02:00
jp9000
8830c4102f obs-studio UI: Implement stream settings UI
- Updated the services API so that it links up with an output and
   the output gets data from that service rather than via settings.
   This allows the service context to have control over how an output is
   used, and makes it so that the URL/key/etc isn't necessarily some
   static setting.

   Also, if the service is attached to an output, it will stick around
   until the output is destroyed.

 - The settings interface has been updated so that it can allow the
   usage of service plugins.  What this means is that now you can create
   a service plugin that can control aspects of the stream, and it
   allows each service to create their own user interface if they create
   a service plugin module.

 - Testing out saving of current service information.  Saves/loads from
   JSON in to obs_data_t, seems to be working quite nicely, and the
   service object information is saved/preserved on exit, and loaded
   again on startup.

 - I agonized over the settings user interface for days, and eventually
   I just decided that the only way that users weren't going to be
   fumbling over options was to split up the settings in to simple/basic
   output, pre-configured, and then advanced for advanced use (such as
   multiple outputs or services, which I'll implement later).

   This was particularly painful to really design right, I wanted more
   features and wanted to include everything in one interface but
   ultimately just realized from experience that users are just not
   technically knowledgable about it and will end up fumbling with the
   settings rather than getting things done.

   Basically, what this means is that casual users only have to enter in
   about 3 things to configure their stream:  Stream key, audio bitrate,
   and video bitrate.  I am really happy with this interface for those
   types of users, but it definitely won't be sufficient for advanced
   usage or for custom outputs, so that stuff will have to be separated.

 - Improved the JSON usage for the 'common streaming services' context,
   I realized that JSON arrays are there to ensure sorting, while
   forgetting that general items are optimized for hashing.  So
   basically I'm just using arrays now to sort items in it.
2014-04-24 02:19:03 -07:00
jp9000
43057038fc Add 'common' and 'custom' RTMP services
This plugin is just a generic service plugin for basic RTMP streaming
service stuff.

This just has a 'common' service that has a list of common/simple
streaming services that don't have their own custom service modules, and
then a 'custom' service that allows you to enter in the stream URL and
key manually, without a service/server list.

Also, copy the jansson VS projects file (don't modify the old one) so
that it's located in the vs/2013 directory, so that other libraries can
properly link with it without having to enter in extra information just
to include jansson
2014-04-19 20:54:18 -07:00
jp9000
a4a52d1c87 Fix bug where packets weren't interleaving
Packets were not interleaving, thus new data was being sent out with
potentially non-monotonically increasing timestamps
2014-04-14 02:02:59 -07:00
BtbN
075820028f Improve bundle fixup 2014-04-13 11:05:46 -07:00
jp9000
b427397aa9 RTMP output: Implement frame drop code
A little bit of history about frame dropping:

I did a large number of experiments with frame dropping in old versions
of OBS1, and it's not an easy thing to deal with.  I tried just about
everything from standard i-frame delay, to large buffers, to dumping
packets, to super-unnecessarily-complex things that just ended up
causing more problems than they was worth.

When I did my experiments, I found that the most ideal frame drop system
(in terms of reducing the amount of total data that needed to be
dropped) was in the 0.4xx days where I had a 3 second frame-drop buffer
where I could calculate the actual buffer size in bytes, and then
intellgently choose packets in that buffer to trim it down to a specific
size while minimizing the number of p-frames and i-frames dropped, and
preventing the actual impact of dropped frames on the stream.  The
downside of it was that it required too much extra latency, and far too
many people complained about it, so it was removed in favor of the
current system.

The current system I just refer to just as 'packet dumping', which when
combined with low keyframe intervals (like most services use these
days), is the next-best method from my experience.  Just dump the buffer
when you reach a threshold of buffering (which I prefer to measure with
time rather than in size), then wait for a new i-frame.  Simple,
effective, and reduces the risk of consecutive buffering, while still
having fairly low impact on the stream output due to the low keyframe
interval of services.

By the way, audio will not (and should not ever) be dropped, lest you
end up with syncing issues (among other nasty things) specific to server
implementation.
2014-04-12 04:34:15 -07:00
jp9000
f98c006711 Merge branch 'master' of https://github.com/jp9000/obs-studio 2014-04-10 12:03:59 -07:00
jp9000
519c4f4118 Fix issue when using multiple video encoders
- Fix an issue that could occur when using more than one video encoder.
   Audio/video would not sync up correctly because they were expected to
   be paired with a particular encoder.  This simply adds a little
   helper variable to encoder packets that specifies the system time in
   microseconds.  We then use that system time to sync

 - Fix an issue with x264 with fractional FPS rates (29.97 and 59.94
   particularly) where it would create ridiculously large stream
   outputs.  The problem was that you shouldn't set the timebase_*
   variables in the x264 params manually, let x264 handle the default
   values for it and leave them at 0.

 - Make x264 use CFR output, because there's no reason to ever use VFR
   in this case.
2014-04-10 11:59:42 -07:00
Palana
d0e3f0d6a3 Fix (debug build) warnings in librtmp 2014-04-08 15:57:21 +02:00
Palana
d45248d6ad Add preprocessor flag for librtmp network dumps
Fixes debug compilation on non-WIN32 targets due to undefined
netstackdump(_read) symbols
2014-04-08 15:41:12 +02:00
jp9000
92522d1886 Implement RTMP module (still needs drop code)
- Implement the RTMP output module.  This time around, we just use a
   simple FLV muxer, then just write to the stream with RTMP_Write.
   Easy and effective.

 - Fix the FLV muxer, the muxer now outputs proper FLV packets.

 - Output API:
   * When using encoders, automatically interleave encoded packets
     before sending it to the output.

   * Pair encoders and have them automatically wait for the other to
     start to ensure sync.

   * Change 'obs_output_signal_start_fail' to 'obs_output_signal_stop'
     because it was a bit confusing, and doing this makes a lot more
     sense for outputs that need to stop suddenly (disconnections/etc).

 - Encoder API:
   * Remove some unnecessary encoder functions from the actual API and
     make them internal.  Most of the encoder functions are handled
     automatically by outputs anyway, so there's no real need to expose
     them and end up inadvertently confusing plugin writers.

   * Have audio encoders wait for the video encoder to get a frame, then
     start at the exact data point that the first video frame starts to
     ensure the most accrate sync of video/audio possible.

   * Add a required 'frame_size' callback for audio encoders that
     returns the expected number of frames desired to encode with.  This
     way, the libobs encoder API can handle the circular buffering
     internally automatically for the encoder modules, so encoder
     writers don't have to do it themselves.

 - Fix a few bugs in the serializer interface.  It was passing the wrong
   variable for the data in a few cases.

 - If a source has video, make obs_source_update defer the actual update
   callback until the tick function is called to prevent threading
   issues.
2014-04-07 22:00:10 -07:00
jp9000
906535022f Add window capture
Now that we have the priorties window in we can finally be able to
select windows for capture source such as window capture.  Only took
about an hour or two to write.

Also, fixed some depednency issues on winmm.lib with obs-outputs
2014-04-07 01:20:36 -07:00
Timo R
15639d928c Add compatiblity for some older ffmpeg versions 2014-04-05 16:12:32 +02:00
jp9000
bd331c8ffe Remove the weird size stuff from OBS_DECLARE_MODULE
Instead of doing this, just use macros to handle this situation.

Also, fix a minor bug in AAC encoder
2014-04-05 01:45:53 -07:00
jp9000
7bfe15e4a9 AAC: Use obs_data_set_default_int function 2014-04-05 01:17:32 -07:00
jp9000
cabe98cb4e Add FFmpeg's AAC enoder
This just adds FFmpeg's default AAC encoder as an audio encoder.  Going
to try to start getting things going with the RTMP output library next.
2014-04-05 01:13:11 -07:00
jp9000
8c74db9ffc Add packet interleaving and improve encoder API
- Add interleaving of video/audio packets for outputs that are encoded
   and expect both video and audio data, sorting the packets and sending
   them to the output when both video and audio is received.

 - Combine create and initialize callbacks for the encoder API callback
   interface.
2014-04-04 23:21:19 -07:00
Palana
42be968759 Make OBS basic and obs-ffmpeg-output use NV12 by default 2014-04-04 20:55:38 +02:00
jp9000
1bca7e0a3e Improve properties API
Improve the properties API so that it can actually respond somewhat to
user input.  Maybe later this might be further improved or replaced with
something script-based.

When creating a property, you can now add a callback to that property
that notifies when the property has been changed in the user interface.
Return true if you want the properties to be refreshed, or false if not.
Though now that I think about it I doubt there would ever be a case
where you would have this callback and *not* refresh the properties.

Regardless, this allows functions to change the values of properties or
settings, or enable/disable/hide other property controls from view
dynamically.
2014-04-04 00:30:37 -07:00
jp9000
4a652ec82d obs-output module: Fill out more functions
- Add start/stop code to obs-output module

 - Use a circular buffer for the buffered encoder packets instead of a
   dynamic array

 - Add pthreads.lib as a dependency to obs-output module on windows in
   visual studio project files

 - Fix an windows export bug for avc parsing functions on windows.
   Also, rename those functions to be more consistent with each other.

 - Make outputs use a single function for encoded data rather than
   multiple functions

 - Add the ability to make 'text' properties be passworded
2014-04-02 00:42:12 -07:00
BtbN
293fa069f0 Remove hard dependency on PulseAudio 2014-04-01 22:19:57 +02:00
BtbN
84bfb6e80b Add missing project directives 2014-04-01 21:19:31 +02:00
jp9000
c751d080e9 obs-outputs module: Use the correct deps variable 2014-04-01 12:06:17 -07:00
jp9000
0cf9e0cfdd Add preliminary FLV/RTMP output (incomplete)
- obs-outputs module:  Add preliminary code to send out data, and add
   an FLV muxer.  This time we don't really need to build the packets
   ourselves, we can just use the FLV muxer and send it directly to
   RTMP_Write and it should automatically parse the entire stream for us
   without us having to do much manual code at all.  We'll see how it
   goes.

 - libobs:  Add AVC NAL packet parsing code

 - libobs/media-io:  Add quick helper functions for audio/video to get
   the width/height/fps/samplerate/etc rather than having to query the
   info structures each time.

 - libobs (obs-output.c):  Change 'connect' signal to 'start' and 'stop'
   signals.  'start' now specifies an error code rather than whether it
   simply failed, that way the client can actually know *why* a failure
   occurred.  Added those error codes to obs-defs.h.

 - libobs:  Add a few functions to duplicate/free encoder packets
2014-04-01 11:55:18 -07:00
jp9000
ed6fc7b122 Add librtmp to obs-outputs
Note that this is a somewhat heavily modified custom version of librtmp.
I modified all the platform specific code that we were using for the
OBS1 to make it platform-independent.

I don't really like the code in this library, but it works well enough,
so I can't really fault anyone for it.  It's just very..  unclean.  Even
for a C library, quite unclean.  Some parts are also a little less safe
than I'd prefer as well.
2014-04-01 11:48:28 -07:00
jp9000
6da26a3a1c Implement encoder usage with outputs
- Make it so that encoders can be assigned to outputs.  If an encoder
   is destroyed, it will automatically remove itself from that output.
   I specifically didn't want to do reference counting because it leaves
   too much potential for unchecked references and it just felt like it
   would be more trouble than it's worth.

 - Add a 'flags' value to the output definition structure.  This lets
   the output specify if it uses video/audio, and whether the output is
   meant to be used with OBS encoders or not.

 - Remove boilerplate code for outputs.  This makes it easier to program
   outputs.  The boilerplate code involved before was mostly just
   involving connecting to the audio/video data streams directly in each
   output plugin.

   Instead of doing that, simply add plugin callback functions for
   receiving video/audio (either encoded or non-encoded, whichever it's
   set to use), and then call obs_output_begin_data_capture and
   obs_output_end_data_capture to automatically handle setting up
   connections to raw or encoded video/audio streams for the plugin.

 - Remove 'active' function from output callbacks, as it's no longer
   really needed now that the libobs output context automatically knows
   when the output is active or not.

 - Make it so that an encoder cannot be destroyed until all data
   connections to the encoder have been removed.

 - Change the 'start' and 'stop' functions in the encoder interface to
   just an 'initialize' callback, which initializes the encoder.

 - Make it so that the encoder must be initialized first before the data
   stream can be started.  The reason why initialization was separated
   from starting the encoder stream was because we need to be able to
   check that the settings used with the encoder *can* be used first.

   This problem was especially annoying if you had both video/audio
   encoding.  Before, you'd have to check the return value from
   obs_encoder_start, and if that second encoder fails, then you
   basically had to stop the first encoder again, making for
   unnecessary boilerplate code whenever starting up two encoders.
2014-03-27 21:50:15 -07:00
jp9000
d9251f9e87 Add source properties window (very preliminary)
- Add a properties window for sources so that you can now actually edit
   the settings for sources.  Also, display the source by itself in the
   window (Note: not working on mac, and possibly not working on linux).

   When changing the settings for a source, it will call
   obs_source_update on that source when you have modified any values
   automatically.

 - Add a properties 'widget', eventually I want to turn this in to a
   regular nice properties view like you'd see in the designer, but
   right now it just uses a form layout in a QScrollArea with regular
   controls to display the properties.  It's clunky but works for the
   time being.

 - Make it so that swap chains and the main graphics subsystem will
   automatically use at least one backbuffer if none was specified

 - Fix bug where displays weren't added to the main display array

 - Make it so that you can get the properties of a source via the actual
   pointer of a source/encoder/output in addition to being able to look
   up properties via identifier.

 - When registering source types, check for required functions (wasn't
   doing it before).  getheight/getwidth should not be optional if it's
   a video source as well.

 - Add an RAII OBSObj wrapper to obs.hpp for non-reference-counted
   libobs pointers

 - Add an RAII OBSSignal wrapper to obs.hpp for libobs signals to
   automatically disconnect them on destruction

 - Move the "scale and center" calculation in window-basic-main.cpp to
   its own function and in its own source file

 - Add an 'update' callback to WASAPI audio sources
2014-03-23 01:07:54 -07:00
jp9000
154e0c59e1 Use atomic functions where appropriate
Also, rename atomic functions to be consistent with the rest of the
platform/threading functions, and move atomic functions to threading*
files rather than platform* files
2014-03-16 18:26:46 -07:00
jp9000
3ed647b8a0 Set defaults automatically
Automatically query defaults for sources/outputs/encoders and set them
before calling create
2014-03-16 17:42:37 -07:00
jp9000
fd37d9e9a8 Implement encoder interface (still preliminary)
- Implement OBS encoder interface.  It was previously incomplete, but
   now is reaching some level of completion, though probably should
   still be considered preliminary.

   I had originally implemented it so that encoders only have a 'reset'
   function to reset their parameters, but I felt that having both a
   'start' and 'stop' function would be useful.

   Encoders are now assigned to a specific video/audio media output each
   rather than implicitely assigned to the main obs video/audio
   contexts.  This allows separate encoder contexts that aren't
   necessarily assigned to the main video/audio context (which is useful
   for things such as recording specific sources).  Will probably have
   to do this for regular obs outputs as well.

   When creating an encoder, you must now explicitely state whether that
   encoder is an audio or video encoder.

   Audio and video can optionally be automatically converted depending
   on what the encoder specifies.

   When something 'attaches' to an encoder, the first attachment starts
   the encoder, and the encoder automatically attaches to the media
   output context associated with it.  Subsequent attachments won't have
   the same effect, they will just start receiving the same encoder data
   when the next keyframe plays (along with SEI if any).  When detaching
   from the encoder, the last detachment will fully stop the encoder and
   detach the encoder from the media output context associated with the
   encoder.

   SEI must actually be exported separately; because new encoder
   attachments may not always be at the beginning of the stream, the
   first keyframe they get must have that SEI data in it.  If the
   encoder has SEI data, it needs only add one small function to simply
   query that SEI data, and then that data will be handled automatically
   by libobs for all subsequent encoder attachments.

 - Implement x264 encoder plugin, move x264 files to separate plugin to
   separate necessary dependencies.

 - Change video/audio frame output structures to not use const
   qualifiers to prevent issues with non-const function usage elsewhere.
   This was an issue when writing the x264 encoder, as the x264 encoder
   expects non-const frame data.

   Change stagesurf_map to return a non-const data type to prevent this
   as well.

 - Change full range parameter of video scaler to be an enum rather than
   boolean
2014-03-16 16:21:34 -07:00
jp9000
04d07831cc CoreAudio: If null device id, just set to default 2014-03-11 19:45:02 -07:00
jp9000
ae1fffef7a CoreAudio: Set default audio settings on creation
device_id would end up being null, which would mess with the functions.
2014-03-11 19:42:04 -07:00
jp9000
74a3dfcf69 Fix potential uninitialized variable
if (data->output->flags & AVFMT_RAWPICTURE)

If this was true, the 'ret' variable would be used without
initialization.
2014-03-11 16:07:22 -07:00
jp9000
6578c8b03e FFmpeg plugin: Fix null pointer reference 2014-03-11 14:46:34 -07:00
jp9000
2d6a7c89ca Remove trailing whitespaces from linux plugins 2014-03-11 10:12:54 -07:00
Jim
88e4e7f1be Merge pull request #49 from fryshorts/linux-input
linux input plugins for desktop and audio capture
2014-03-11 10:07:09 -07:00
jp9000
afc798f712 Also make sure the mutex unlocks
Otherwise deadlock
2014-03-11 09:16:16 -07:00
jp9000
c09a2efc3c FFmpeg plugin: Add a few checks to be safe
Make sure it locks the write mutex before freeing the packets, and put
the detach code in the main thread loop rather than off in a separate
function for clarity
2014-03-11 09:14:21 -07:00
fryshorts
32c8cd00c5 Fixed usage of event functions
The event functions got renamed in obs.
2014-03-11 14:16:03 +01:00
fryshorts
c0ab8fadda moved and split up the linux xshm and pulseaudio capture plugins 2014-03-11 14:06:10 +01:00
jp9000
5e1cac68f4 Fix semaphore mac code and mac plugin
Didn't convert the event names and didn't have the right mac includes
2014-03-10 19:24:09 -07:00
jp9000
585fd8f969 Fix audio streaming and mac semaphores
...The reason why audio didn't work was because I overwrote the bitrate
values.

As for semaphores, mac doesn't support unnamed semaphores without using
mach semaphores.  So, I just implemented a semaphore wrapper for each
OS.
2014-03-10 19:04:00 -07:00
jp9000
806837873a CoreAudio: fix properties for input/output
Also, check that audio devices are available before setting defaults
2014-03-10 13:59:15 -07:00
jp9000
02a07ea0a0 Add preliminary streaming code for testing
- Add some temporary streaming code using FFmpeg.  FFmpeg itself is not
   very ideal for streaming; lack of direct control of the sockets and
   no framedrop handling means that FFmpeg is definitely not something
   you want to use without wrapper code.  I'd prefer writing my own
   network framework in this particular case just because you give away
   so much control of the network interface.  Wasted an entire day
   trying to go through FFmpeg issues.

   There's just no way FFmpeg should be used for real streaming (at
   least without being patched or submitting some sort of patch, but I'm
   sort of feeling "meh" on that idea)

   I had to end up writing multiple threads just to handle both
   connecting and writing, because av_interleaved_write_frame blocks
   every call, stalling the main encoder thread, and thus also stalling
   draw signals.

 - Add some temporary user interface for streaming settings.  This is
   just temporary for the time being.  It's in the outputs section of
   the basic-mode settings

 - Make it so that dynamic arrays do not free all their data when the
   size just happens to be reduced to 0.  This prevents constant
   reallocation when an array keeps going from 1 item to 0 items.  Also,
   it was bad to become dependent upon that functionality.  You must now
   always explicitly call "free" on it to ensure the data is free, and
   that's how it should be.  Implicit functionality can lead to
   confusion and maintainability issues.
2014-03-10 13:10:35 -07:00
jp9000
f2ee950746 Activate user-selected audio devices
- Fix a bug where the initial audio data insertion would cause all
   audio data to unintentionally clear (mixed up < and > operators, damn
   human error)

 - Fixed a potential interdependant lock scenario with channel mutex
   locks and graphics mutex locks.  The main video thread could lock the
   graphics mutex and then while in the graphics mutex could lock the
   channels mutex.  Meanwhile in another thread, the channel mutex could
   get locked, and then the graphics mutex would get locked, causing a
   deadlock.

   The best way to deal with this is to not let mutexes lock within
   other mutexes, but sometimes it's difficult to avoid such as in the
   main video thread.

 - Audio devices should now be functional, and the devices in the audio
   settings can now be changed as desired.
2014-03-07 17:03:34 -07:00
jp9000
2c3a3f4e65 WASAPI: Change some errors messages to warnings
There shouldn't be errors if the actual source has successfully been
created, just warnings.
2014-03-07 13:04:38 -07:00
jp9000
7d48dbb1dc Add a way to get default settings
- Implement a means of obtaining default settings for an
   input/output/encoder.  obs_source_defaults for example will return
   the default settings for a particular source type.

 - Because C++ doesn't have designated initializers, use functions in
   the WASAPI plugin to register the sources instead.
2014-03-07 06:55:21 -07:00
jp9000
2448d0f229 Load up the lists of audio devices in settings
It will now load up a the list of audio input/output devices in the
combo boxes in audio settings.
2014-03-06 07:02:25 -07:00
jp9000
4f7ab552df Reimplement monitor capture
- Implement windows monitor capture (code is so much cleaner than in
   OBS1).  Will implement duplication capture later

 - Add GDI texture support to d3d11 graphics library

 - Fix precision issue with sleep timing, you have to call
   timeBeginPeriod otherwise windows sleep will be totally erratic.
2014-03-05 10:43:14 -07:00
jp9000
3415960d02 WASAPI: Check the HRESULT values with FAILED
I can't believe I did !res there.  Well I suppose I can believe it, but
still.
2014-03-04 07:18:24 -07:00
jp9000
bec8a09bd9 CoreAudio: Separate enumeration code
The enumeration code being up at the top was making things quite messy,
so I split that code out to a separate set of files.
2014-03-04 07:10:33 -07:00
jp9000
348588254c Add WASAPI audio capture
- Add WASAPI audio capture for windows, input and output

 - Check for null pointer in os_dlopen

 - Add exception-safe 'WinHandle' and 'CoTaskMemPtr' helper classes that
   will automatically call CloseHandle on handles and call CoTaskMemFree
   on certain types of memory returned from windows functions

 - Changed the wide <-> MBS/UTF8 conversion functions so that you use
   buffers (like these functions are *supposed* to behave), and changed
   the ones that allocate to a different naming scheme to be safe
2014-03-04 07:07:13 -07:00
jp9000
2fd57ed7f5 CoreAudio: Don't reconnect if no output devices
Somehow this code didn't get included with the last commit.
2014-03-03 05:12:58 -07:00
jp9000
91644fbf23 CoreAudio: Fail if no output device found
Also, don't have it repeat trying to reconnect if no devices are found
2014-03-03 03:21:00 -07:00
jp9000
9c6da6f52d Split output/input audio capture sources
- Split input and output audio captures so that they're different
   sources.  This allows easier handling and enumeration of audio
   devices without having to do some sort of string processing.

   This way the user interface code can handle this a bit more easily,
   and so that it doesn't confuse users either.  This should be done for
   all audio capture sources for all operating systems.  You don't have
   to duplicate any code, you just need to create input/output wrapper
   functions to designate the audio as input or output before creation.

 - Make it detect soundflower and wavtap devices as mac "output" devices
   (even though they're actually input) for the mac output capture, and
   make it so that users can select a default output capture and
   automatically use soundflower or wavtap.

   I'm not entirely happy about having to do this, but because mac is
   designed this way, this is really the only way to handle it that
   makes it easier for users and UI code to deal with.

   Note that soundflower and wavtap are still also designated as input
   devices, so will still show up in input device enumeration.

 - Remove pragma messages because they were kind polluting the other
   compiler messages and just getting in the way.  In the future we can
   just do a grep for TODO to find them.

 - Redo list property again, this time using a safer internal array,
   rather than requiring sketchy array inputs.  Having functions handle
   everything behind the scenes is much safer.

 - Remove the reference counter debug log code, as it was included
   unintentionally in a commit.
2014-03-03 02:56:54 -07:00
jp9000
f716de1331 CoreAudio: Detect default device change
If the default device changes, set the reconnect interval to 200
milliseconds so it pretty much immediately tries to reinitialize the
audio with the newly selected default device.  Otherwise, use 2000
millisecond intervals, and assume disconnection.

Also, reduced FFmpeg logging to just regular FFmpeg information rather
than everything FFmpeg logs.
2014-02-28 21:46:22 -07:00
jp9000
771eac6015 Be more consistent about log levels
LOG_ERROR should be used in places where though recoverable (or at least
something that can be handled safely), was unexpected, and may affect
the user/application.

LOG_WARNING should be used in places where it's not entirely unexpected,
is recoverable, and doesn't really affect the user/application.
2014-02-28 20:02:29 -07:00
jp9000
4e10eeda09 Wrap FFmpeg operations in mutexes, switch to MP4
I can't believe I wasn't doing this.  This is why file output was
getting corrupted.  Audio and video send in data from separate threads.
I should be embarassed for not having considered that.

Key lesson:  Increase threading paranoia levels.  Apparently my
threading paranoid levels are lackluster.
2014-02-28 03:50:30 -07:00
jp9000
f9809847cd Use MP4s when not on windows
Also, make it use 'veryfast' preset.  Still testing this, might have to
revise this later.
2014-02-27 23:14:03 -07:00
jp9000
a4792b9469 Merge branch 'master' of https://github.com/jp9000/obs-studio 2014-02-27 12:23:57 -08:00
jp9000
1927dc7eaa Add callback for device format change (CoreAudio) 2014-02-27 12:22:58 -08:00
jp9000
9236b940a2 Fix audio startup (CoreAudio)
Forgot to add a '!'.
2014-02-27 04:12:41 -07:00
jp9000
9e8c003282 Remove redundant connect message 2014-02-27 00:32:03 -07:00
jp9000
702c364ceb Fix a memory leak in ca_warn (CoreAudio) 2014-02-27 00:20:43 -07:00
jp9000
1a5220acf1 Fix more failure handling for CoreAudio
Actually, if initializing failed at all, it would never properly
uninitialize because the 'initialized' variable was never set until the
very end.  Instead, set the "initialized" flag from the beginning to
ensure initialization.
2014-02-27 00:17:35 -07:00
jp9000
c519933eb1 Fix a case where audio wouldn't free correctly
If coreaudio_start failed, it wouldn't free the audio data properly.
Fixed that issue.
2014-02-27 00:14:50 -07:00
jp9000
4c19a60e16 Fix device disconnect detection for CoreAudio
These address structures are very confusing and I wish apple designed
better system APIs.
2014-02-26 23:06:33 -08:00
jp9000
33dc028c7e Add mac audio capture
- Add CoreAudio device input capture for mac audio capturing.  The code
   should cover just about everything for capturing mac input device
   audio.  Because of the way mac audio is designed, users may have no
   choice but to obtain the open source soundflower software to capture
   their mac's desktop audio.  It may be necessary for us to distribute
   it with the program as well.

 - Hide event backend

 - Use win32 events for windows

 - Allow timed waits for events

 - Fix a few warnings
2014-02-26 22:43:31 -08:00
jp9000
a1a1f1a64c Fix stereo output bug with ffmpeg test output 2014-02-24 01:51:39 -07:00
jp9000
6c2d067e05 Make ffmpeg test output sync A/V properly
FFmpeg test output wasn't make any attempt to sync data before.  Should
be much more accurate now.

Also, added a restart message to audio settings if base audio settings
are changed.
2014-02-24 01:48:14 -07:00
jp9000
c232ebde15 Implement a few more audio options/functions
Implement a few audio options in to the user interface as well as a few
inline audio functions in audio-io.h.

Make it so ffmpeg plugin automatically converts to the desired format.

Use regular interleaved float internally for audio instead of planar
float.
2014-02-23 16:27:19 -07:00
jp9000
f2d4de3c03 Implement automatic video scaling (if requested)
Add a scaler interface (defaults to swscale), and if a separate output
wants to use a different scale or format than the default output format,
allow a scaler instance to be created automatically for that output,
which will then receive the new scaled output.
2014-02-18 13:37:56 -07:00
Palana
1044fa0e86 Add Libavutil dependency for obs-ffmpeg plugin
av_frame_alloc, av_frame_free, among others, live in libavutil
2014-02-18 15:06:32 +01:00
jp9000
30094a5919 Implement auto output resampling (if requested)
If there are for example more than one audio outputs and they have
different sample rates or channels and such, this will allow automatic
conversion of that audio to the request formats/channels/rates (but only
if requested).
2014-02-17 20:23:20 -07:00
jp9000
2dbbffe4a2 Make a number of key optimizations
- Changed glMapBuffer to glMapBufferRange to allow invalidation.  Using
   just glMapBuffer alone was causing some unacceptable stalls.

 - Changed dynamic buffers from GL_DYNAMIC_WRITE to GL_STREAM_WRITE
   because I had misunderstood the OpenGL specification

 - Added _OPENGL and _D3D11 builtin preprocessor macros to effects to
   allow special processing if needed

 - Added fmod support to shaders (NOTE: D3D and GL do not function
   identically with negative numbers when using this.  Positive numbers
   however function identically)

 - Created a planar conversion shader that converts from packed YUV to
   planar 420 right on the GPU without any CPU processing.  Reduces
   required GPU download size to approximately 37.5% of its normal rate
   as well.  GPU usage down by 10 entire percentage points despite the
   extra required pass.
2014-02-16 19:28:21 -07:00
jp9000
8b8217f68e Fix a some more linux/GCC specific warnings 2014-02-14 15:56:01 -07:00
jp9000
966b943d5b Remove majority of warnings
There were a *lot* of warnings, managed to remove most of them.

Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
2014-02-14 15:13:36 -07:00
jp9000
8e81d8be56 Revamp API and start using doxygen
The API used to be designed in such a way to where it would expect
exports for each individual source/output/encoder/etc.  You would export
functions for each and it would automatically load those functions based
on a specific naming scheme from the module.

The idea behind this was that I wanted to limit the usage of structures
in the API so only functions could be used.  It was an interesting idea
in theory, but this idea turned out to be flawed in a number of ways:

 1.) Requiring exports to create sources/outputs/encoders/etc meant that
     you could not create them by any other means, which meant that
     things like faruton's .net plugin would become difficult.

 2.) Export function declarations could not be checked, therefore if you
     created a function with the wrong parameters and parameter types,
     the compiler wouldn't know how to check for that.

 3.) Required overly complex load functions in libobs just to handle it.
     It makes much more sense to just have a load function that you call
     manually.  Complexity is the bane of all good programs.

 4.) It required that you have functions of specific names, which looked
     and felt somewhat unsightly.

So, to fix these issues, I replaced it with a more commonly used API
scheme, seen commonly in places like kernels and typical C libraries
with abstraction.  You simply create a structure that contains the
callback definitions, and you pass it to a function to register that
definition (such as obs_register_source), which you call in the
obs_module_load of the module.

It will also automatically check the structure size and ensure that it
only loads the required values if the structure happened to add new
values in an API change.

The "main" source file for each module must include obs-module.h, and
must use OBS_DECLARE_MODULE() within that source file.

Also, started writing some doxygen documentation in to the main library
headers.  Will add more detailed documentation as I go.
2014-02-12 08:04:50 -07:00
jp9000
1b8bd57dac Do test recording to a specified file
It will now output to a a filename that you specify when you click the
record button.  This is just for testing.
2014-02-10 10:22:35 -07:00
jp9000
590a486343 Updated cmake files for ffmpeg plugin
Also, fixed an enum name issue.  No clue why visual
studio actually compiled that without warnings/errors
2014-02-10 07:14:51 -08:00
jp9000
b067440f73 Use bzalloc instead of bmalloc then memset
Reduces needless code repetition and still allows for proper memory
alignment.  Cleans up the code a bit.
2014-02-09 12:34:07 -07:00
jp9000
6c92cf5841 Implement output, improve video/audio subsystems
- Fill in the rest of the FFmpeg test output code for testing so it
   actually properly outputs data.

 - Improve the main video subsystem to be a bit more optimal and
   automatically output I420 or NV12 if needed.

 - Fix audio subsystem insertation and byte calculation.  Now it will
   seamlessly insert new audio data in to the audio stream based upon
   its timestamp value.  (Be extremely cautious when using floating
   point calculations for important things like this, and always round
   your values and check your values)

 - Use 32 byte alignment in case of future optimizations and export a
   function to get the current alignment.

 - Make os_sleepto_ns return true if slept, false if the time has
   already been passed before the call.

 - Fix sinewave output so that it actually properly calculates a middle
   C sinewave.

 - Change the use of row_bytes to linesize (also makes it a bit more
   consistent with FFmpeg's naming as well)
2014-02-09 05:51:06 -07:00
jp9000
3d6d43225f Add planar audio support, improve test output
- Add planar audio support.  FFmpeg and libav use planar audio for many
  encoders, so it was somewhat necessary to add support in libobs
  itself.

- Improve/adjust FFmpeg test output plugin.  The exports were somewhat
  messed up (making me rethink how exports should be done).  Not yet
  functional; it handles video properly, but it still does not handle
  audio properly.

- Improve planar video code.  The planar video code was not properly
  accounting for row sizes for each plane.  Specifying row sizes for
  each plane has now been added.  This will also make it more compatible
  with FFmpeg/libav.

- Fixed a bug where callbacks wouldn't create properly in audio-io and
  video-io code.

- Implement 'blogva' function to allow for va_list usage with libobs
  logging.
2014-02-07 03:03:54 -07:00
BtbN
074f9627b7 Fixup OSX Rpath for imported external libraries on install 2014-01-28 23:07:49 +01:00
jp9000
6c44291693 Implement settings interface for plugins
Add a fairly easy to use settings interface that can be passed to
plugins, and replaced the old character string system that was being
used before.  The new data interface allows for an easier method of
getting/altering settings for plugins, and is built to be serializable
to/from JSON.

Also, removed another wxFormBuilder file that was no longer in use.
2014-01-27 23:14:58 -07:00
BtbN
45ec80fb7d Full rewrite of all CMakeLists
CMake now works on all platforms
2014-01-24 18:56:32 +01:00
jp9000
a3867aecde Make minor fix to new output code 2014-01-20 01:40:15 -07:00
jp9000
fc8851e9f4 Add preliminary ffmpeg plugin (still testing)
- Added some code for FFmpeg output that I'm still playing around with.
  Right now I'm just trying to get it to output to file and try to
  understand the FFmpeg/libav APIs.  Hopefully in the future this plugin
  can be used for any sort of output to FFmpeg.

- Fixed a cast warning in audio-io.c with size_t -> uint32_t

- Renamed the 'video_info' and 'audio_info' structures to
  'video_conver_info' and 'audio_convert_info' to better represent their
  actual purpose, and to avoid confusion with 'audio_output_info' and
  'video_output_info' structures.

- Removed a few macros from obs-def.h that were at one point going to be
  used but no longer going to be used (at least for now)
2014-01-19 03:16:41 -07:00
jp9000
29b7d3621c Add preliminary output/encoder interface
- First, I redid the output interface for libobs.  I feel like it's
  going in a pretty good direction in terms of design.

  Right now, the design is so that outputs and encoders are separate.
  One or more outputs can connect to a specific encoder to receive its
  data, or the output can connect directly to raw data from libobs
  output itself, if the output doesn't want to use a designated encoder.
  Data is received via callbacks set when you connect to the encoder or
  raw output.  Multiple outputs can receive the data from a single
  encoder context if need be (such as for streaming to multiple channels
  at once, and/or recording with the same data).

  When an encoder is first connected to, it will connect to raw output,
  and start encoding.  Additional connections will receive that same
  data being encoded as well after that.  When the last encoder has
  disconnected, it will stop encoding.  If for some reason the encoder
  needs to stop, it will use the callback with NULL to signal that
  encoding has stopped.  Some of these things may be subject to change
  in the future, though it feels pretty good with this design so far.
  Will have to see how well it works out in practice versus theory.

- Second, Started adding preliminary RTMP/x264 output plugin code.

  To speed things up, I might just make a direct raw->FFmpeg output to
  create a quick output plugin that we can start using for testing all
  the subsystems.
2014-01-16 22:34:51 -07:00
jp9000
62c2b1d74e Simplify media i/o interfaces
Completely revamped the entire media i/o data and handlers.  The
original idea was to have a system that would have connecting media
inputs and outputs, but at a certain point I realized that this was an
unnecessary complexity for what we wanted to do.  (Also, it reminded me
of directshow filters, and I HATE directshow with a passion, and
wouldn't wish it upon my greatest enemy)

Now, audio/video outputs are connected to directly, with better callback
handlers, and will eventually have the ability to automatically handle
conversions such as 4:4:4 to 4:2:0 when connecting to an input that uses
them.  Doing this will allow the video/audio i/o handlers to also
prevent duplicate conversion, as well as make it easier/simple to use.

My true goal for this is to make output and encoder plugins as simple to
create as possible.  I want to be able to be able to create an output
plugin with almost no real hassle of having to worry about image
conversions, media inputs/outputs, etc.  A plugin developer shouldn't
have to handle that sort of stuff when he/she doesn't really need to.

Plugins will be able to simply create a callback via obs_video() and/or
obs_audio(), and they will automatically receive the audio/video data in
the formats requested via a simple callback, without needing to do
almost anything else at all.
2014-01-14 01:58:47 -07:00
jp9000
8298fa4dc7 With the permission of my fellow contributors, I'm switching obs-studio back to GPL v2+ to prevent issues between this project and the original OBS project, and for personal reasons to avoid legal ambiguity (not political reasons, I admittedly would prefer GPL v3+) 2013-12-02 22:24:38 -07:00
jp9000
409b011a8e cleaned up main internal data structure design, changed to reference counting for sources to ensure safe destruction of source objects from all parts of the system, added some service-related stuff for testing 2013-11-20 15:00:16 -07:00
jp9000
146e9a7dbd added support for jansson, added new output files, made some adjustments to the API, fixed a UI subclass issue 2013-11-13 06:24:20 -07:00
jp9000
f5e41f441e added initial main program and directshow files, finally have a UI functioning 2013-11-07 16:45:03 -07:00