Asterisk - The Open Source Telephony Project  18.5.0
stasis_app_playback.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * David M. Lee, II <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 #ifndef _ASTERISK_STASIS_APP_PLAYBACK_H
20 #define _ASTERISK_STASIS_APP_PLAYBACK_H
21 
22 /*! \file
23  *
24  * \brief Stasis Application Playback API. See \ref res_stasis "Stasis
25  * Application API" for detailed documentation.
26  *
27  * \author David M. Lee, II <[email protected]>
28  * \since 12
29  */
30 
31 #include "asterisk/stasis_app.h"
32 
33 /*! Opaque struct for handling the playback of a single file */
34 struct stasis_app_playback;
35 
36 /*! State of a playback operation */
38  /*! The playback has not started yet */
40  /*! The media is currently playing */
42  /*! The media is currently playing */
44  /*! The media is transitioning to the next in the list */
46  /*! The media has stopped playing */
48  /*! The playback was canceled. */
50  /*! The playback was stopped. */
52  /*! Enum end sentinel. */
54 };
55 
56 /*! Valid operation for controlling a playback. */
58  /*! Stop the playback operation. */
60  /*! Restart the media from the beginning. */
62  /*! Pause playback. */
64  /*! Resume paused playback. */
66  /*! Rewind playback. */
68  /*! Fast forward playback. */
70  /*! Enum end sentinel. */
72 };
73 
75  /*! The target is a channel */
77  /*! The target is a bridge */
79 };
80 
81 /*!
82  * \brief Play a file to the control's channel.
83  *
84  * Note that the file isn't the full path to the file. Asterisk's internal
85  * playback mechanism will automagically select the best format based on the
86  * available codecs for the channel.
87  *
88  * \param control Control for \c res_stasis.
89  * \param media Array of const char * media files to play.
90  * \param media_count The number of media files in \c media.
91  * \param language Selects the file based on language.
92  * \param target_id ID of the target bridge or channel.
93  * \param target_type What the target type is
94  * \param skipms Number of milliseconds to skip for forward/reverse operations.
95  * \param offsetms Number of milliseconds to skip before playing.
96  * \param id ID to assign the new playback or NULL for default.
97  * \return Playback control object.
98  * \return \c NULL on error.
99  */
101  struct stasis_app_control *control, const char **media,
102  size_t media_count, const char *language, const char *target_id,
103  enum stasis_app_playback_target_type target_type,
104  int skipms, long offsetms, const char *id);
105 
106 /*!
107  * \brief Gets the current state of a playback operation.
108  *
109  * \param playback Playback control object.
110  * \return The state of the \a playback object.
111  */
113  struct stasis_app_playback *playback);
114 
115 /*!
116  * \brief Gets the unique id of a playback object.
117  *
118  * \param playback Playback control object.
119  * \return \a playback's id.
120  * \return \c NULL if \a playback ic \c NULL
121  */
122 const char *stasis_app_playback_get_id(
123  struct stasis_app_playback *playback);
124 
125 /*!
126  * \brief Finds the playback object with the given id.
127  *
128  * \param id Id of the playback object to find.
129  * \return Associated \ref stasis_app_playback object.
130  * \return \c NULL if \a id not found.
131  */
133 
134 /*!
135  * \brief Convert a playback to its JSON representation
136  *
137  * \param playback The playback object to convert to JSON
138  *
139  * \retval \c NULL on error
140  * \retval A JSON object on success
141  */
143  const struct stasis_app_playback *playback);
144 
149 };
150 /*!
151  * \brief Controls the media for a given playback operation.
152  *
153  * \param playback Playback control object.
154  * \param control Media control operation.
155  * \return \c STASIS_PLAYBACK_OPER_OK on success.
156  * \return \ref stasis_playback_oper_results indicating failure.
157  */
159  struct stasis_app_playback *playback,
160  enum stasis_app_playback_media_operation operation);
161 
162 /*!
163  * \brief Message type for playback updates. The data is an
164  * \ref ast_channel_blob.
165  */
167 
168 #endif /* _ASTERISK_STASIS_APP_PLAYBACK_H */
enum stasis_playback_oper_results stasis_app_playback_operation(struct stasis_app_playback *playback, enum stasis_app_playback_media_operation operation)
Controls the media for a given playback operation.
stasis_app_playback_target_type
stasis_app_playback_media_operation
struct ast_json * stasis_app_playback_to_json(const struct stasis_app_playback *playback)
Convert a playback to its JSON representation.
struct stasis_app_playback * stasis_app_playback_find_by_id(const char *id)
Finds the playback object with the given id.
const char * stasis_app_playback_get_id(struct stasis_app_playback *playback)
Gets the unique id of a playback object.
const ast_string_field media
enum stasis_app_playback_state stasis_app_playback_get_state(struct stasis_app_playback *playback)
Gets the current state of a playback operation.
struct stasis_message_type * stasis_app_playback_snapshot_type(void)
Message type for playback updates. The data is an ast_channel_blob.
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:117
stasis_playback_oper_results
static int skipms
struct stasis_app_playback * stasis_app_control_play_uri(struct stasis_app_control *control, const char **media, size_t media_count, const char *language, const char *target_id, enum stasis_app_playback_target_type target_type, int skipms, long offsetms, const char *id)
Play a file to the control&#39;s channel.
stasis_app_playback_state
Abstract JSON element (object, array, string, int, ...).
Stasis Application API. See Stasis Application API for detailed documentation.