Prepare Audio Receiver

This commit is contained in:
Florian Märkl 2018-11-29 17:48:06 +01:00
commit bd434921ae
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
5 changed files with 102 additions and 3 deletions

View file

@ -36,7 +36,7 @@ set(SOURCE_FILES
src/ecdh.c
src/launchspec.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)
include_directories("${NANOPB_SOURCE_DIR}")

View 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

View file

@ -26,6 +26,7 @@
#include "rpcrypt.h"
#include "takion.h"
#include "ecdh.h"
#include "audio.h"
#include <stdint.h>
#include <netdb.h>
@ -65,8 +66,16 @@ typedef struct chiaki_quit_event_t
ChiakiQuitReason reason;
} 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
{
@ -74,11 +83,12 @@ typedef struct chiaki_event_t
union
{
ChiakiQuitEvent quit;
ChiakiAudioStreamInfoEvent audio_stream_info;
};
} ChiakiEvent;
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;
void *event_cb_user;
ChiakiAudioFrameCallback audio_frame_cb;
void *audio_frame_cb_user;
ChiakiThread session_thread;
@ -132,6 +144,12 @@ static inline void chiaki_session_set_event_cb(ChiakiSession *session, ChiakiEve
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)
{
if(session->quit_reason != CHIAKI_QUIT_REASON_NONE)

33
lib/src/audioreceiver.c Normal file
View 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)
{
}