/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FRAME_EXTRACTOR_H_
#define FRAME_EXTRACTOR_H_

#include <stdio.h>
#include <stdbool.h>

#define ARGB_PIXEL_SIZE 4

typedef struct _frame_extractor frame_extractor;

/**
 *  Create frame extractor for video. Should be free with destroy_frame_extractor
 *
 *  @param file_path[in]    the file path to video file
 *  @return                 pointer to a new frame_extractor data struct
 */
frame_extractor * frame_extractor_create(const char *file_path);

/**
 *  Reassign frame extractor for new video.
 *
 *  @param extractor[in]    pointer to extractor
 *  @param file_path[in]    the file path to video file
 *  @return                 true if success, false otherwise
 */
bool frame_extractor_change_file(frame_extractor *extractor, const char *path_to_file);

/**
 *  Destroy video frame extractor
 *
 *  @param extractor[in]    pointer to extractor
 */
void frame_extractor_destroy(frame_extractor *extractor);

/**
 *  Get size of video frame
 *
 *  @param extractor[in]    pointer to extractor
 *  @param width[out]       width of frame
 *  @param height[out]      height of frame
 */
void frame_extractor_size_get(const frame_extractor *extractor, int *width, int *height);

/**
 *  Get duration of video in milliseconds
 *
 *  @param extractor[in]    pointer to extractor
 *  @param duration[out]    duration of video
 */
void frame_extractor_duration_get(const frame_extractor *extractor, int *duration);

/**
 *  Get duration of video in milliseconds
 *
 *  @param extractor[in]    pointer to extractor
 *  @param frame[out]       new buffer of frame in ARGB32 colorspace. Size of buffer = width*height*4(byte)
 *                          Should be freed with free()
 *  @param pos[in]          position of frame in milliseconds;
 *  @return                 true if success, false otherwise
 */
bool frame_extractor_frame_get(const frame_extractor *extractor, unsigned char **frame, int pos);


#endif /* FRAME_EXTRACTOR_H_ */
