Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upipe_http_src: add support for ranged request #21

Merged
merged 1 commit into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 55 additions & 0 deletions include/upipe-modules/upipe_http_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,61 @@ extern "C" {

#define UPIPE_HTTP_SRC_SIGNATURE UBASE_FOURCC('h','t','t','p')

/** @This extends upipe_command with specific commands for http source. */
enum upipe_http_src_command {
UPIPE_HTTP_SRC_SENTINEL = UPIPE_CONTROL_LOCAL,

/** returns the reading position of the current http request, in octets
* (uint64_t *) */
UPIPE_HTTP_SRC_GET_POSITION,
/** asks to get at the given position (uint64_t), using Range header */
UPIPE_HTTP_SRC_SET_POSITION,
/** asks to get at the given position (uint64_t), the given size
* (uint64_t), using Range header */
UPIPE_HTTP_SRC_SET_RANGE,
};

/** @This returns the reading position of the current http request.
*
* @param upipe description structure of the pipe
* @param position_p filled in with the reading position, in octets
* @return an error code
*/
static inline int upipe_http_src_get_position(struct upipe *upipe,
uint64_t *position_p)
{
return upipe_control(upipe, UPIPE_HTTP_SRC_GET_POSITION,
UPIPE_HTTP_SRC_SIGNATURE, position_p);
}

/** @This request the given position using Range header
*
* @param upipe description structure of the pipe
* @param position new reading position, in octets (between 0 and the size)
* @return an error code
*/
static inline int upipe_http_src_set_position(struct upipe *upipe,
uint64_t position)
{
return upipe_control(upipe, UPIPE_HTTP_SRC_SET_POSITION,
UPIPE_HTTP_SRC_SIGNATURE, position);
}

/** @This request the given range
*
* @param upipe description structure of the pipe
* @param offset range starts at offset, in octets
* @param length octets to read from offset, in octets
* @return an error code
*/
static inline int upipe_http_src_set_range(struct upipe *upipe,
uint64_t offset,
uint64_t length)
{
return upipe_control(upipe, UPIPE_HTTP_SRC_SET_RANGE,
UPIPE_HTTP_SRC_SIGNATURE, offset, length);
}

/** @This returns the management structure for all http sources.
*
* @return pointer to manager
Expand Down