Skip to content

Commit

Permalink
extended the example as well as the vapi
Browse files Browse the repository at this point in the history
  • Loading branch information
naxuroqa committed Apr 21, 2014
1 parent f45be31 commit ced952b
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 25 deletions.
10 changes: 6 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PKG_CHECK_MODULES_FULLPATH(GDKX11 REQUIRED gdk-x11-3.0)
PKG_CHECK_MODULES_FULLPATH(SQLITE REQUIRED sqlite3>=3.7)
PKG_CHECK_MODULES_FULLPATH(JSON REQUIRED json-glib-1.0>=0.14)
PKG_CHECK_MODULES_FULLPATH(TOX REQUIRED libtoxcore>=0.0)
PKG_CHECK_MODULES_FULLPATH(TOXAV REQUIRED libtoxav>=0.0)

IF(APPLE)
PKG_CHECK_MODULES_FULLPATH(OVERLAY REQUIRED gdk-x11-3.0)
Expand Down Expand Up @@ -86,10 +87,11 @@ SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS}
${GIO_CFLAGS} ${GIO_CFLAGS_OTHER}
${GLIB_CFLAGS} ${GLIB_CFLAGS_OTHER}
${GSTREAMER_CFLAGS} ${GSTREAMER_CFLAGS_OTHER}
${GDKX11_CFLAGS} ${GDKX11_CFLAGS_OTHER}
${OVERLAY_CFLAGS} ${OVERLAY_CFLAGS_OTHER}
${SQLITE_CFLAGS} ${SQLITE_CFLAGS_OTHER}
${JSON_CFLAGS} ${JSON_CFLAGS_OTHER}
${TOX_CFLAGS} ${TOX_CFLAGS_OTHER}
${TOXAV_CFLAGS} ${TOXAV_CFLAGS_OTHER}
)

# since pkg_check_modules returns semicolon
Expand Down Expand Up @@ -169,7 +171,6 @@ VALA_PRECOMPILE( VALA_C_TOXAV_TEST
tox-1.0
gtk+-3.0
OPTIONS
--debug
--target-glib=${TARGET_GLIB}
--vapidir=${CMAKE_SOURCE_DIR}/src/vapi
-D ${OS_DEFINES}
Expand Down Expand Up @@ -209,8 +210,9 @@ TARGET_LINK_LIBRARIES( venom

TARGET_LINK_LIBRARIES( toxav_test
${TOX_LIBRARIES}
${TOXAV_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GDKX11_LIBRARIES}
${OVERLAY_LIBRARIES}
${GTK_LIBRARIES}
)

Expand All @@ -219,4 +221,4 @@ INSTALL(TARGETS venom RUNTIME DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINA
# add tests
ADD_SUBDIRECTORY(testing)

# vim:set ts=2 sw=2 et:
# vim:set ts=2 sw=2 et:
26 changes: 25 additions & 1 deletion src/testing/ToxAVTest.vala
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
/*
* Example taken from https://wiki.gnome.org/Projects/Vala/GStreamerSample
* ToxAVTest.vala
*
* Copyright (C) 2013-2014 Venom authors and contributors
*
* This file is part of Venom.
*
* Venom 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.
*
* Venom 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 Venom. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Using example code from https://wiki.gnome.org/Projects/Vala/GStreamerSample
*/

using Gtk;
using Gst;

public class VideoSample : Window {

private Tox.Tox tox;
private ToxAV.ToxAV tox_av;
private DrawingArea drawing_area;
private Pipeline pipeline;
private Element src;
Expand All @@ -18,6 +40,8 @@ public class VideoSample : Window {
public VideoSample () {
create_widgets ();
setup_gst_pipeline ();
tox = new Tox.Tox(0);
//tox_av = new ToxAV.ToxAV(tox, 800, 600);
}

private void create_widgets () {
Expand Down
169 changes: 149 additions & 20 deletions src/vapi/tox-1.0.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,67 @@ namespace Tox {
}
}

namespace Vpx {
[CCode (cname = "vpx_img_fmt_t", cprefix = "VPX_IMG_FMT_", has_type_id = false)]
public enum ImageFormat {
RGB24, // 24 bit per pixel packed RGB
RGB32, // 32 bit per pixel packed 0RGB
RGB565, // 16 bit per pixel, 565
RGB555, // 16 bit per pixel, 555
UYVY, // UYVY packed YUV
YUY2, // YUYV packed YUV
YVYU, // YVYU packed YUV
BGR24, // 24 bit per pixel packed BGR
RGB32_LE, // 32 bit packed BGR0
ARGB, // 32 bit packed ARGB, alpha=255
ARGB_LE, // 32 bit packed BGRA, alpha=255
RGB565_LE, // 16 bit per pixel, gggbbbbb rrrrrggg
RGB555_LE, // 16 bit per pixel, gggbbbbb 0rrrrrgg
YV12, // planar YVU
VPXI420 // < planar 4:2:0 format with vpx color space
}

[CCode (cname = "vpx_image_t", free_function = "vpx_image_free", cprefix = "vpx_image_", has_type_id = false)]
public class Image {
[CCode (cname = "fmt")]
public ImageFormat fmt;
[CCode (cname = "w")]
public uint w;
[CCode (cname = "h")]
public uint h;
[CCode (cname = "d_w")]
public uint d_w;
[CCode (cname = "d_h")]
public uint d_h;
[CCode (cname = "x_chroma_shift")]
public uint x_chroma_shift;
[CCode (cname = "y_chroma_shift")]
public uint y_chroma_shift;
[CCode (cname = "planes")]
public uint8[][] planes;
[CCode (cname = "stride")]
public int[] stride;
[CCode (cname = "bps")]
public int bps;
//void* user_priv
[CCode (cname = "img_data")]
public uint8[] img_data;
[CCode (cname = "img_data_owner")]
public int img_data_owner;
[CCode (cname = "self_alloced")]
public int self_alloced;

[CCode (cname = "vpx_image_alloc")]
public Image(ImageFormat fmt, uint d_w, uint d_h, uint align);

public Image wrap(ImageFormat fmt, uint d_w, uint d_h, uint align, [CCode(array_length=false)] uint8[] img_data);

public int set_rect(uint x, uint y, uint w, uint h);

public void flip();
}
}

[CCode (cheader_filename = "tox/toxav.h", cprefix = "")]
namespace ToxAV {

Expand All @@ -674,7 +735,7 @@ namespace ToxAV {
/**
* @brief Callbacks ids that handle the call states.
*/
[CCode (cname = "ToxAvCallbackID", cprefix = "", has_type_id = false)]
[CCode (cname = "ToxAvCallbackID", cprefix = "av_", has_type_id = false)]
public enum CallbackID {
/* Requests */
OnInvite,
Expand Down Expand Up @@ -731,35 +792,34 @@ namespace ToxAV {
*
* @param messenger The messenger handle.
* @param useragent The agent handling A/V session (i.e. phone).
* @param ua_name Useragent name.
* @param video_width Width of video frame.
* @param video_height Height of video frame.
* @return ToxAv*
* @retval NULL On error.
*/
//FIXME what do about userdata/useragent
//public ToxAV(Tox.Tox messenger, void *useragent, const char *ua_name, uint16_t video_width, uint16_t video_height);
[CCode (cname = "toxav_new")]
public ToxAV(Tox.Tox messenger, uint16 video_width, uint16 video_height);

//only here for completeness
/**
* @brief Remove A/V session.
*
* @param av Handler.
* @return void
*/
/* #### only here for completeness #### */
///**
// * @brief Remove A/V session.
// *
// * @param av Handler.
// * @return void
// */
//void toxav_kill(ToxAv *av);

//[CCode(has_target = false)]
//public delegate void ToxAVCallback( void *arg );

/**
* @brief Register callback for call state.
*
* @param callback The callback
* @param id One of the ToxAvCallbackID values
* @return void
*/
//public void register_callstate_callback (ToxAVCallback callback, ToxAvCallbackID id);

[CCode (cname = "ToxAVCallback", has_type_id = false)]
public delegate int Callback ();
public static void register_callstate_callback (Callback callback, CallbackID id);

/**
* @brief Call user. Use its friend_id.
*
Expand Down Expand Up @@ -855,7 +915,7 @@ namespace ToxAV {
* @retval 0 Success.
* @retval ToxAvError On Error.
*/
//public AV_Error recv_video ( vpx_image_t **output);
public AV_Error recv_video ( out Vpx.Image output);

/**
* @brief Receive decoded audio frame.
Expand All @@ -879,7 +939,7 @@ namespace ToxAV {
* @retval 0 Success.
* @retval ToxAvError On error.
*/
//public AV_Error send_video ( vpx_image_t *input);
public AV_Error send_video ( Vpx.Image input);

/**
* @brief Encode and send audio frame.
Expand All @@ -904,13 +964,82 @@ namespace ToxAV {
*/
public AV_Error get_peer_transmission_type ( int peer );

/**
* @brief Get id of peer participating in conversation
*
* @param av Handler
* @param peer peer index
* @return int
* @retval ToxAvError No peer id
*/
public AV_Error get_peer_id ( int peer );

/**
* @brief Get reference to an object that is handling av session.
*
* @param av Handler.
* @return void*
*/
//void *toxav_get_agent_handler ( ToxAv *av );
//public void *get_agent_handler ();

/**
* @brief Is video encoding supported
*
* @param av Handler
* @return int
* @retval 1 Yes.
* @retval 0 No.
*/
public int video_encoding {
[CCode (cname = "toxav_video_encoding")] get;
}

/**
* @brief Is video decoding supported
*
* @param av Handler
* @return int
* @retval 1 Yes.
* @retval 0 No.
*/
public int video_decoding {
[CCode (cname = "toxav_video_decoding")] get;
}

/**
* @brief Is audio encoding supported
*
* @param av Handler
* @return int
* @retval 1 Yes.
* @retval 0 No.
*/
public int audio_encoding {
[CCode (cname = "toxav_audio_encoding")] get;
}

/**
* @brief Is audio decoding supported
*
* @param av Handler
* @return int
* @retval 1 Yes.
* @retval 0 No.
*/
public int audio_decoding {
[CCode (cname = "toxav_audio_decoding")] get;
}

/**
* @brief Get messenger handle
*
* @param av Handler.
* @return Tox*
*/
public Tox.Tox tox_handle {
[CCode (cname = "toxav_get_tox")] get;
}
}
}


}

0 comments on commit ced952b

Please sign in to comment.