Skip to content

Conversation

troman123
Copy link

@troman123 troman123 commented Sep 6, 2023

Description

according to rfc6416, This adds AAC support to obs-webrtc
https://datatracker.ietf.org/doc/rfc6416/

Motivation and Context

My motivation is to support RTP AAC in WebRTC according to RFC-6416.

How Has This Been Tested?

All testing during development was performed on macos-13.5.1 (22G90).
used aac encoder:
FFmpeg aac
coreaudio aac

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@pkviet
Copy link
Member

pkviet commented Sep 6, 2023

Thanks for your contribution. There are some formal issues.

  • Please fill the template, especially motivation and tests.
  • Also run clang-format on your code.
  • your commit has no message. A description is mandatory.

In particular, tests with our various aac encoders would be useful:

  • FFmpeg aac
  • coreaudio
  • fdk-aac

You'll also have to fix the CI issues. Check the CI logs ; seems flatpak and macos do not build.

@pkviet pkviet added Seeking Testers Build artifacts on CI New Feature New feature or plugin labels Sep 6, 2023
@pkviet
Copy link
Member

pkviet commented Sep 6, 2023

windows CI doesn't pass either:
D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(142,17): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(142,17): error C2220: the following warning is treated as an error [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(264,4): error C2065: 'RTC_CODEC_AAC': undeclared identifier [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(271,17): error C2078: too many initializers [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(275,3): error C3861: 'rtcSetAACPacketizationHandler': identifier not found [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj]

@derrod derrod marked this pull request as draft September 6, 2023 08:59
@tytan652
Copy link
Collaborator

tytan652 commented Sep 6, 2023

Requires libdatachannel 0.19.0 stable release

@pkviet pkviet removed the Seeking Testers Build artifacts on CI label Sep 6, 2023
@tytan652 tytan652 added Compile Issue There are issues getting this PR compiled Dependency Issue Issue is in external library or dependency, not OBS itself labels Sep 6, 2023
@pkviet
Copy link
Member

pkviet commented Sep 6, 2023

Requires libdatachannel 0.19.0 stable release

ah, aac was added to libdatachannel on august 23 indeed by the same author.
@troman123 if you want to pass CI, you'll have to point build-spec.json to your fork of obs-deps which incorporate the update of libdatachannel to 0.19 stable release (in a separate commit which will be dropped upon eventual merge)
I'd suggest you also PR the libdatachannel update to obs-deps.
Also, for flatpak, you'll have to have a commit to point to 0.19 stable.

@troman123
Copy link
Author

@pkviet , thanks for your suggestion, i will follow those steps to fix

@pkviet
Copy link
Member

pkviet commented Sep 6, 2023

@pkviet , thanks for your suggestion, i will follow those steps to fix

Also fill the template and fix the commit message, as I pointed earlier.
It's not in mergeable state otherwise.

@troman123 troman123 force-pushed the aac branch 3 times, most recently from db3d477 to fe69dc1 Compare September 6, 2023 12:44
@troman123 troman123 closed this Sep 6, 2023
@troman123 troman123 reopened this Sep 6, 2023
@troman123
Copy link
Author

windows CI doesn't pass either: D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(142,17): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(142,17): error C2220: the following warning is treated as an error [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(264,4): error C2065: 'RTC_CODEC_AAC': undeclared identifier [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(271,17): error C2078: too many initializers [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj] D:\a\obs-studio\obs-studio\plugins\obs-webrtc\whip-output.cpp(275,3): error C3861: 'rtcSetAACPacketizationHandler': identifier not found [D:\a\obs-studio\obs-studio\build_x64\plugins\obs-webrtc\obs-webrtc.vcxproj]

fixed

@troman123 troman123 marked this pull request as ready for review September 7, 2023 02:29
@troman123
Copy link
Author

Thanks for your contribution. There are some formal issues.

  • Please fill the template, especially motivation and tests.
  • Also run clang-format on your code.
  • your commit has no message. A description is mandatory.

In particular, tests with our various aac encoders would be useful:

  • FFmpeg aac
  • coreaudio
  • fdk-aac

You'll also have to fix the CI issues. Check the CI logs ; seems flatpak and macos do not build.

done

@troman123 troman123 marked this pull request as draft September 7, 2023 05:06
@Sean-Der
Copy link
Contributor

@troman123 Would you mind rebasing this PR? Master now has the obs-deps you need!

@troman123 troman123 marked this pull request as ready for review May 7, 2024 09:46
according to rfc6416, This adds AAC support to obs-webrtc

Signed-off-by: troman <[email protected]>
@troman123
Copy link
Author

@troman123 Would you mind rebasing this PR? Master now has the obs-deps you need!

Sorry, the pr conflict has been resolved now.

@troman123
Copy link
Author

@Sean-Der @RytoEX

@MarcoMayCry
Copy link

Tested on MacOS and works. (FFmpeg AAC / CoreAudio AAC)
More, WHIP HEVC #10159 has been tested and works. (Apple VT HEVC Hardware Encoder)

image

@troman123
Copy link
Author

@Sean-Der @RytoEX I have rebased the master. can be ready for merging now. thank you.

@RytoEX RytoEX removed Compile Issue There are issues getting this PR compiled Dependency Issue Issue is in external library or dependency, not OBS itself labels Aug 23, 2024
Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick scan. I might need someone else who understands WebRTC/WHIP to clarify and clean up the code comments.

Comment on lines +93 to +116

if (is_aac) {
/*
// Latm to write, StreamMuxConfig:out of band
// RFC6416 6.3. Fragmentation of MPEG-4 Audio Bitstream (p17)
// It is RECOMMENDED to put one audioMuxElement in each RTP packet. If
// the size of an audioMuxElement can be kept small enough that the size
// of the RTP packet containing it does not exceed the size of the Path
// MTU, this will be no problem.
// in this case , PayloadLengthInfo will not be writen in rtp payload.

uint8_t buf[1200] = {0};
// PayloadLengthInfo()
int header_size = packet->size/0xFF + 1;
memset(buf, 0xFF, header_size - 1);
buf[header_size - 1] = packet->size % 0xFF;

//PayloadMux
memcpy(buf + header_size, packet->data, packet->size);

Send(buf, header_size + packet->size, duration, audio_track);
*/
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this just adding a large comment block?

@@ -1,6 +1,5 @@
#include "whip-output.h"
#include "whip-utils.h"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove this line.

Comment on lines +154 to +164
if (object_type == 5 /*AOT_SBR*/
|| (object_type == 29 /*AOT_PS*/ &&
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
if (object_type == 29 /*AOT_PS*/)
ps = 1;
ext_object_type = 5 /*AOT_SBR*/;
sbr = 1;

ext_sample_rate = get_sample_rate(&gb, &ext_sampling_index);
object_type = get_object_type(&gb);
if (object_type == 22 /*AOT_ER_BSAC*/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see these object_type values as an enum.

}
specific_config_bitindex = gb.bit_index;

//no support AOT_ALS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//no support AOT_ALS
// no support AOT_ALS

@Sean-Der
Copy link
Contributor

Sean-Der commented Aug 23, 2024

Sorry I didn't look at this sooner!

Would it be possible to put non-OBS specific code upstream? Other projects could benefit from this, and want to keep the OBS+WebRTC code maintainable.

I am 100% in support of AAC though. Anything that makes it easier for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature New feature or plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants