mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 13:33:13 -07:00
Prepare Audio Receiver
This commit is contained in:
parent
e0bef511b2
commit
bd434921ae
5 changed files with 102 additions and 3 deletions
|
@ -4,6 +4,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
void audio_frame_cb(uint8_t *buf, size_t buf_size, void *user)
|
||||||
|
{
|
||||||
|
printf("AUDIO FRAME CB %lu\n", buf_size);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
if(argc != 7)
|
if(argc != 7)
|
||||||
|
@ -42,6 +47,7 @@ int main(int argc, const char *argv[])
|
||||||
|
|
||||||
ChiakiSession session;
|
ChiakiSession session;
|
||||||
chiaki_session_init(&session, &connect_info);
|
chiaki_session_init(&session, &connect_info);
|
||||||
|
chiaki_session_set_audio_frame_cb(&session, audio_frame_cb, NULL);
|
||||||
chiaki_session_start(&session);
|
chiaki_session_start(&session);
|
||||||
chiaki_session_join(&session);
|
chiaki_session_join(&session);
|
||||||
chiaki_session_fini(&session);
|
chiaki_session_fini(&session);
|
||||||
|
|
|
@ -36,7 +36,7 @@ set(SOURCE_FILES
|
||||||
src/ecdh.c
|
src/ecdh.c
|
||||||
src/launchspec.c
|
src/launchspec.c
|
||||||
src/random.c
|
src/random.c
|
||||||
src/gkcrypt.c src/audio.c)
|
src/gkcrypt.c src/audio.c include/chiaki/audioreceiver.h src/audioreceiver.c)
|
||||||
|
|
||||||
add_subdirectory(protobuf)
|
add_subdirectory(protobuf)
|
||||||
include_directories("${NANOPB_SOURCE_DIR}")
|
include_directories("${NANOPB_SOURCE_DIR}")
|
||||||
|
|
42
lib/include/chiaki/audioreceiver.h
Normal file
42
lib/include/chiaki/audioreceiver.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Chiaki.
|
||||||
|
*
|
||||||
|
* Chiaki is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Chiaki is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHIAKI_AUDIORECEIVER_H
|
||||||
|
#define CHIAKI_AUDIORECEIVER_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct chiaki_audio_receiver_t
|
||||||
|
{
|
||||||
|
struct chiaki_session_t *session;
|
||||||
|
ChiakiLog *log;
|
||||||
|
} ChiakiAudioReceiver;
|
||||||
|
|
||||||
|
CHIAKI_EXPORT void chiaki_audio_receiver_init(ChiakiAudioReceiver *audio_receiver, struct chiaki_session_t *session);
|
||||||
|
CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receiver);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CHIAKI_AUDIORECEIVER_H
|
|
@ -26,6 +26,7 @@
|
||||||
#include "rpcrypt.h"
|
#include "rpcrypt.h"
|
||||||
#include "takion.h"
|
#include "takion.h"
|
||||||
#include "ecdh.h"
|
#include "ecdh.h"
|
||||||
|
#include "audio.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
@ -65,8 +66,16 @@ typedef struct chiaki_quit_event_t
|
||||||
ChiakiQuitReason reason;
|
ChiakiQuitReason reason;
|
||||||
} ChiakiQuitEvent;
|
} ChiakiQuitEvent;
|
||||||
|
|
||||||
|
typedef struct chiaki_audio_stream_info_event_t
|
||||||
|
{
|
||||||
|
ChiakiAudioHeader audio_header;
|
||||||
|
} ChiakiAudioStreamInfoEvent;
|
||||||
|
|
||||||
typedef enum { CHIAKI_EVENT_QUIT } ChiakiEventType;
|
|
||||||
|
typedef enum {
|
||||||
|
CHIAKI_EVENT_QUIT,
|
||||||
|
CHIAKI_EVENT_AUDIO_STREAM_INFO
|
||||||
|
} ChiakiEventType;
|
||||||
|
|
||||||
typedef struct chiaki_event_t
|
typedef struct chiaki_event_t
|
||||||
{
|
{
|
||||||
|
@ -74,11 +83,12 @@ typedef struct chiaki_event_t
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
ChiakiQuitEvent quit;
|
ChiakiQuitEvent quit;
|
||||||
|
ChiakiAudioStreamInfoEvent audio_stream_info;
|
||||||
};
|
};
|
||||||
} ChiakiEvent;
|
} ChiakiEvent;
|
||||||
|
|
||||||
typedef void (*ChiakiEventCallback)(ChiakiEvent *event, void *user);
|
typedef void (*ChiakiEventCallback)(ChiakiEvent *event, void *user);
|
||||||
|
typedef void (*ChiakiAudioFrameCallback)(uint8_t *buf, size_t buf_size, void *user);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,6 +118,8 @@ typedef struct chiaki_session_t
|
||||||
|
|
||||||
ChiakiEventCallback event_cb;
|
ChiakiEventCallback event_cb;
|
||||||
void *event_cb_user;
|
void *event_cb_user;
|
||||||
|
ChiakiAudioFrameCallback audio_frame_cb;
|
||||||
|
void *audio_frame_cb_user;
|
||||||
|
|
||||||
ChiakiThread session_thread;
|
ChiakiThread session_thread;
|
||||||
|
|
||||||
|
@ -132,6 +144,12 @@ static inline void chiaki_session_set_event_cb(ChiakiSession *session, ChiakiEve
|
||||||
session->event_cb_user = user;
|
session->event_cb_user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void chiaki_session_set_audio_frame_cb(ChiakiSession *session, ChiakiAudioFrameCallback cb, void *user)
|
||||||
|
{
|
||||||
|
session->audio_frame_cb = cb;
|
||||||
|
session->audio_frame_cb_user = user;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void chiaki_session_set_quit_reason(ChiakiSession *session, ChiakiQuitReason reason)
|
static inline void chiaki_session_set_quit_reason(ChiakiSession *session, ChiakiQuitReason reason)
|
||||||
{
|
{
|
||||||
if(session->quit_reason != CHIAKI_QUIT_REASON_NONE)
|
if(session->quit_reason != CHIAKI_QUIT_REASON_NONE)
|
||||||
|
|
33
lib/src/audioreceiver.c
Normal file
33
lib/src/audioreceiver.c
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Chiaki.
|
||||||
|
*
|
||||||
|
* Chiaki is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Chiaki is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <chiaki/audioreceiver.h>
|
||||||
|
#include <chiaki/session.h>
|
||||||
|
|
||||||
|
|
||||||
|
CHIAKI_EXPORT void chiaki_audio_receiver_init(ChiakiAudioReceiver *audio_receiver, ChiakiSession *session)
|
||||||
|
{
|
||||||
|
audio_receiver->session = session;
|
||||||
|
audio_receiver->log = &session->log;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receiver)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue