method = infos[0];
path = infos[1];
version = infos[2];
- decoded_path = path;
if (strncmp(path.c_str(), "/file", 5) == 0) {
- std::string key = "", value = "";
- if (!split_key_value(path, "=", key, value)) {
- ERROR("fail to parse path(file) : %s", path.c_str());
- return false;
- }
- if (key != "/file?file") {
- ERROR("unknown request file path (key : %s, value : %s)", key.c_str(), value.c_str());
- return false;
+ std::vector<std::string> tokens;
+ if (split(path.substr(6), '&', tokens) > 0) {
+ for (int i = 0; i < tokens.size(); ++i) {
+ std::string data = tokens[i];
+ std::string key = "", value = "";
+ if (!split_key_value(data, "=", key, value)) {
+ ERROR("fail to request : %s", data.c_str());
+ continue;
+ }
+ if (key == "file") {
+ extension[key] = UriDecoder().decode(value.c_str());;
+ continue;
+ }
+ extension[key] = value;
+ }
}
type = REQ_TYPE_TRANSCODING_FILE;
- decoded_path = UriDecoder().decode(value.c_str());
+
+// DEBUG(":: HEADER :: %s", extension["file"].c_str());
+// std::map<std::string, std::string>::iterator iter = extension.begin();
+// for (; iter != extension.end(); ++iter) {
+// std::string key = iter->first;
+// std::string value = iter->second;
+// DEBUG("[%s] -> [%s]", key.c_str(), value.c_str());
+// }
}
DEBUG("info (%d) -> type : [%s], path : [%s], version : [%s]", infos.size(), method.c_str(), path.c_str(), version.c_str());
RequestType type;
std::string method;
std::string path;
- std::string decoded_path;
std::string version;
std::map<std::string, std::string> params;
+ std::map<std::string, std::string> extension;
public:
bool parse_header(std::string header);
}
else if (rc > 0) {
wc = write(RESPONSE_FD, buffer, rc);
+ //DEBUG("write : %d", wc);
if (wc < rc) {
//DEBUG("need rewrite.. remain (%d)", rc - wc);
int retry_wc = 0;
}
else if (rc > 0) {
wc = write(encoder->get_fd(), buffer, rc);
-
+ //DEBUG("write : %d", wc);
if (wc < rc) {
//DEBUG("need rewrite.. remain (%d)", rc - wc);
int retry_wc = 0;
if (header.parse_header(req)) {
Encoder encoder;
Source *source = 0;
-
ThreadParams thread_params = { 0, &encoder, &header };
int video_pid = 0, audio_pid = 0, pmt_pid = 0;
switch(header.type) {
case REQ_TYPE_TRANSCODING_FILE:
try {
- MpegTS *ts = new MpegTS(header.decoded_path, false);
+ MpegTS *ts = new MpegTS(header.extension["file"], true);
pmt_pid = ts->pmt_pid;
video_pid = ts->video_pid;
audio_pid = ts->audio_pid;
DEBUG("response data :\n%s", response.c_str());
if (header.type == REQ_TYPE_TRANSCODING_FILE) {
- DEBUG("seek to %llu", byte_offset);
- ((MpegTS*)source)->seek_absolute(byte_offset);
- DEBUG("seek ok");
+ try {
+ std::string position = header.extension["position"];
+ if (position == "") {
+ DEBUG("seek to byte_offset %llu", byte_offset);
+ ((MpegTS*)source)->seek_absolute(byte_offset);
+ DEBUG("seek ok");
+ }
+ else {
+ unsigned int position_offset = strtollu(position);
+ if(((MpegTS*)source)->is_time_seekable && (position_offset > 0)) {
+ DEBUG("seek to position_offset %ds", position_offset);
+ ((MpegTS*)source)->seek_time((position_offset * 1000) + ((MpegTS*)source)->first_pcr_ms);
+ DEBUG("seek ok");
+ }
+ }
+ }
+ catch (const trap &e) {
+ WARNING("Exception : %s", e.what());
+ }
}
if (!encoder.ioctl(Encoder::IOCTL_SET_VPID, video_pid)) {