Lines Matching refs:hls

75     hls_t *hls;  in uvoice_hls_index_update()  local
83 hls = loader->hls; in uvoice_hls_index_update()
84 if (!hls) { in uvoice_hls_index_update()
89 os_mutex_lock(hls->lock, OS_WAIT_FOREVER); in uvoice_hls_index_update()
91 if (index < 0 || index >= hls->seg_count) { in uvoice_hls_index_update()
93 os_mutex_unlock(hls->lock); in uvoice_hls_index_update()
97 if (index == hls->seg_index) { in uvoice_hls_index_update()
102 hls->seg_index = index; in uvoice_hls_index_update()
104 target_index = index + hls->seg_begin; in uvoice_hls_index_update()
107 if (!hls->fp) { in uvoice_hls_index_update()
109 os_mutex_unlock(hls->lock); in uvoice_hls_index_update()
112 fseek(hls->fp, 0, SEEK_SET); in uvoice_hls_index_update()
114 if (!hls->content) { in uvoice_hls_index_update()
116 os_mutex_unlock(hls->lock); in uvoice_hls_index_update()
119 hls->pos = hls->content; in uvoice_hls_index_update()
129 if (os_feof(hls->fp)) { in uvoice_hls_index_update()
135 os_fgets(item_desc, sizeof(item_desc), hls->fp); in uvoice_hls_index_update()
140 if (hls->pos - hls->content >= hls->len) { in uvoice_hls_index_update()
145 ptr = strchr(hls->pos, '\n'); in uvoice_hls_index_update()
151 memcpy(item_desc, hls->pos, ptr - hls->pos); in uvoice_hls_index_update()
152 item_desc[ptr - hls->pos] = '\0'; in uvoice_hls_index_update()
154 hls->pos = ptr; in uvoice_hls_index_update()
162 ptr = os_fgets(item_desc, sizeof(item_desc), hls->fp); in uvoice_hls_index_update()
165 os_mutex_unlock(hls->lock); in uvoice_hls_index_update()
171 ptr = strchr(hls->pos, '\n'); in uvoice_hls_index_update()
177 memcpy(item_desc, hls->pos, ptr - hls->pos); in uvoice_hls_index_update()
178 item_desc[ptr - hls->pos] = '\0'; in uvoice_hls_index_update()
180 hls->pos = ptr; in uvoice_hls_index_update()
196 memset(hls->seg_desc, 0, sizeof(hls->seg_desc)); in uvoice_hls_index_update()
197 memcpy(hls->seg_desc, ptr, strlen(ptr) + 1); in uvoice_hls_index_update()
207 if (strlen(hls->seg_desc) + 1 > in uvoice_hls_index_update()
208 HTTP_URL_LEN - (hls->sub - loader->url)) { in uvoice_hls_index_update()
210 os_mutex_unlock(hls->lock); in uvoice_hls_index_update()
213 memset(hls->sub, 0, in uvoice_hls_index_update()
214 HTTP_URL_LEN - (hls->sub - loader->url)); in uvoice_hls_index_update()
215 memcpy(hls->sub, hls->seg_desc, in uvoice_hls_index_update()
216 strlen(hls->seg_desc) + 1); in uvoice_hls_index_update()
220 os_mutex_unlock(hls->lock); in uvoice_hls_index_update()
226 hls_t *hls; in uvoice_hls_file_next() local
233 hls = loader->hls; in uvoice_hls_file_next()
234 if (!hls) { in uvoice_hls_file_next()
239 os_mutex_lock(hls->lock, OS_WAIT_FOREVER); in uvoice_hls_file_next()
242 if (!hls->fp) { in uvoice_hls_file_next()
244 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
249 if (!hls->content) { in uvoice_hls_file_next()
251 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
257 hls->seg_index++; in uvoice_hls_file_next()
259 if (hls->seg_index >= hls->seg_count) { in uvoice_hls_file_next()
262 if (strlen(hls->base) > 0) { in uvoice_hls_file_next()
263 hls->seg_current = hls_index_get(hls->seg_desc); in uvoice_hls_file_next()
264 M_LOGD("current seg %d\n", hls->seg_current); in uvoice_hls_file_next()
268 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
273 memcpy(loader->url, hls->base, in uvoice_hls_file_next()
274 strlen(hls->base) + 1); in uvoice_hls_file_next()
278 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
294 if (os_feof(hls->fp)) { in uvoice_hls_file_next()
300 os_fgets(item_desc, sizeof(item_desc), hls->fp); in uvoice_hls_file_next()
305 if (hls->pos - hls->content >= hls->len) { in uvoice_hls_file_next()
310 ptr = strchr(hls->pos, '\n'); in uvoice_hls_file_next()
316 memcpy(item_desc, hls->pos, ptr - hls->pos); in uvoice_hls_file_next()
317 item_desc[ptr - hls->pos] = '\0'; in uvoice_hls_file_next()
319 hls->pos = ptr; in uvoice_hls_file_next()
327 os_fgets(item_desc, sizeof(item_desc), hls->fp); in uvoice_hls_file_next()
332 ptr = strchr(hls->pos, '\n'); in uvoice_hls_file_next()
334 memcpy(item_desc, hls->pos, ptr - hls->pos); in uvoice_hls_file_next()
335 item_desc[ptr - hls->pos] = '\0'; in uvoice_hls_file_next()
337 memcpy(item_desc, hls->pos, in uvoice_hls_file_next()
338 hls->len - (hls->pos - hls->content)); in uvoice_hls_file_next()
339 item_desc[hls->len - (hls->pos - hls->content)] = '\0'; in uvoice_hls_file_next()
343 hls->pos = ptr; in uvoice_hls_file_next()
348 if (!strncmp(hls->seg_desc, ptr, strlen(ptr) + 1)) { in uvoice_hls_file_next()
362 memset(hls->seg_desc, 0, sizeof(hls->seg_desc)); in uvoice_hls_file_next()
363 memcpy(hls->seg_desc, ptr, strlen(ptr) + 1); in uvoice_hls_file_next()
373 if (strlen(hls->seg_desc) + 1 > in uvoice_hls_file_next()
374 HTTP_URL_LEN - (hls->sub - loader->url)) { in uvoice_hls_file_next()
376 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
379 memset(hls->sub, 0, in uvoice_hls_file_next()
380 HTTP_URL_LEN - (hls->sub - loader->url)); in uvoice_hls_file_next()
381 memcpy(hls->sub, hls->seg_desc, in uvoice_hls_file_next()
382 strlen(hls->seg_desc) + 1); in uvoice_hls_file_next()
386 if (hls->seg_offset) { in uvoice_hls_file_next()
387 hls->seg_offset[hls->seg_index] = in uvoice_hls_file_next()
388 hls->seg_offset[hls->seg_index - 1] + in uvoice_hls_file_next()
391 hls->seg_index, in uvoice_hls_file_next()
392 hls->seg_offset[loader->hls->seg_index]); in uvoice_hls_file_next()
397 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
410 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
415 os_mutex_unlock(hls->lock); in uvoice_hls_file_next()
439 if (loader->hls) { in uvoice_hls_build()
440 if (loader->hls->fp) in uvoice_hls_build()
441 os_fclose(loader->hls->fp); in uvoice_hls_build()
442 if (loader->hls->content) in uvoice_hls_build()
443 snd_free(loader->hls->content); in uvoice_hls_build()
444 if (loader->hls->seg_offset) in uvoice_hls_build()
445 snd_free(loader->hls->seg_offset); in uvoice_hls_build()
446 os_mutex_free(loader->hls->lock); in uvoice_hls_build()
447 snd_free(loader->hls); in uvoice_hls_build()
448 loader->hls = NULL; in uvoice_hls_build()
455 hls_t *hls = loader->hls; in uvoice_hls_build() local
456 if (hls) { in uvoice_hls_build()
457 if (hls->fp) { in uvoice_hls_build()
458 os_fclose(hls->fp); in uvoice_hls_build()
459 hls->fp = NULL; in uvoice_hls_build()
461 if (hls->content) { in uvoice_hls_build()
462 snd_free(hls->content); in uvoice_hls_build()
463 hls->content = NULL; in uvoice_hls_build()
465 if (hls->seg_offset) { in uvoice_hls_build()
466 snd_free(hls->seg_offset); in uvoice_hls_build()
467 hls->seg_offset = NULL; in uvoice_hls_build()
469 os_mutex_free(hls->lock); in uvoice_hls_build()
470 hls->len = 0; in uvoice_hls_build()
471 hls->pos = NULL; in uvoice_hls_build()
472 hls->seg_begin = 0; in uvoice_hls_build()
473 hls->seg_count = 0; in uvoice_hls_build()
474 hls->seg_index = 0; in uvoice_hls_build()
477 hls = snd_zalloc(sizeof(hls_t), AFM_EXTN); in uvoice_hls_build()
478 if (!hls) { in uvoice_hls_build()
482 hls->live_stream = HTTP_LIVE_STREAM_ENABLE; in uvoice_hls_build()
498 snd_free(hls); in uvoice_hls_build()
499 if (loader->hls) in uvoice_hls_build()
500 loader->hls = NULL; in uvoice_hls_build()
506 snd_free(hls); in uvoice_hls_build()
507 if (loader->hls) in uvoice_hls_build()
508 loader->hls = NULL; in uvoice_hls_build()
518 snd_free(hls); in uvoice_hls_build()
519 if (loader->hls) in uvoice_hls_build()
520 loader->hls = NULL; in uvoice_hls_build()
532 snd_free(hls); in uvoice_hls_build()
533 if (loader->hls) in uvoice_hls_build()
534 loader->hls = NULL; in uvoice_hls_build()
550 hls->fp = os_fopen(temp_name, "w+"); in uvoice_hls_build()
551 if (!hls->fp) { in uvoice_hls_build()
555 snd_free(hls); in uvoice_hls_build()
556 if (loader->hls) in uvoice_hls_build()
557 loader->hls = NULL; in uvoice_hls_build()
567 snd_free(hls); in uvoice_hls_build()
568 if (loader->hls) in uvoice_hls_build()
569 loader->hls = NULL; in uvoice_hls_build()
573 hls->len = loader->content_length; in uvoice_hls_build()
574 hls->content = snd_zalloc(hls->len, AFM_EXTN); in uvoice_hls_build()
575 if (!hls->content) { in uvoice_hls_build()
578 snd_free(hls); in uvoice_hls_build()
579 if (loader->hls) in uvoice_hls_build()
580 loader->hls = NULL; in uvoice_hls_build()
583 hls->pos = hls->content; in uvoice_hls_build()
584 M_LOGD("hls content len %d\n", hls->len); in uvoice_hls_build()
589 if (os_fwrite(nc->buffer, 1, nc->head_data_size, hls->fp) != in uvoice_hls_build()
592 os_fclose(hls->fp); in uvoice_hls_build()
593 snd_free(hls); in uvoice_hls_build()
594 if (loader->hls) in uvoice_hls_build()
595 loader->hls = NULL; in uvoice_hls_build()
600 memcpy(hls->pos, nc->buffer, nc->head_data_size); in uvoice_hls_build()
601 hls->pos += nc->head_data_size; in uvoice_hls_build()
624 ret = os_fwrite(nc->buffer, 1, rd_ret, hls->fp); in uvoice_hls_build()
626 M_LOGE("write failed %d!\n", os_ferror(hls->fp)); in uvoice_hls_build()
630 if (hls->pos + rd_ret - hls->content > hls->len) { in uvoice_hls_build()
634 memcpy(hls->pos, nc->buffer, rd_ret); in uvoice_hls_build()
637 hls->pos += rd_ret; in uvoice_hls_build()
657 os_fseek(hls->fp, 0, OS_SEEK_SET); in uvoice_hls_build()
659 hls->pos = hls->content; in uvoice_hls_build()
662 hls->seg_begin = -1; in uvoice_hls_build()
666 if (os_feof(hls->fp)) { in uvoice_hls_build()
672 os_fgets(item_desc, sizeof(item_desc), hls->fp); in uvoice_hls_build()
676 if (hls->pos - hls->content >= hls->len) { in uvoice_hls_build()
681 ptr = strchr(hls->pos, '\n'); in uvoice_hls_build()
687 memcpy(item_desc, hls->pos, ptr - hls->pos); in uvoice_hls_build()
688 item_desc[ptr - hls->pos] = '\0'; in uvoice_hls_build()
690 hls->pos = ptr; in uvoice_hls_build()
705 os_fgets(item_desc, sizeof(item_desc), hls->fp); in uvoice_hls_build()
710 pos_bak = os_ftell(hls->fp); in uvoice_hls_build()
713 ptr = strchr(hls->pos, '\n'); in uvoice_hls_build()
719 if (ptr - hls->pos >= sizeof(item_desc)) { in uvoice_hls_build()
725 memcpy(item_desc, hls->pos, ptr - hls->pos); in uvoice_hls_build()
726 item_desc[ptr - hls->pos] = '\0'; in uvoice_hls_build()
729 hls->pos = ptr; in uvoice_hls_build()
730 pos_bak = (int)hls->pos; in uvoice_hls_build()
741 memset(hls->seg_desc, 0, sizeof(hls->seg_desc)); in uvoice_hls_build()
742 memcpy(hls->seg_desc, ptr, strlen(ptr) + 1); in uvoice_hls_build()
743 if (hls->seg_current > 0) { in uvoice_hls_build()
744 seg_current = hls_index_get(hls->seg_desc); in uvoice_hls_build()
746 seg_current, hls->seg_current); in uvoice_hls_build()
747 if (seg_current <= hls->seg_current) { in uvoice_hls_build()
752 hls->seg_index = seg_index; in uvoice_hls_build()
757 hls->seg_count++; in uvoice_hls_build()
761 hls->seg_begin = atoi(ptr); in uvoice_hls_build()
762 if (hls->seg_begin < 0) in uvoice_hls_build()
765 M_LOGD("media sequence %d\n", hls->seg_begin); in uvoice_hls_build()
789 os_fseek(hls->fp, pos_bak, OS_SEEK_SET); in uvoice_hls_build()
791 hls->pos = (char *)pos_bak; in uvoice_hls_build()
793 hls->duration = (int)duration_sum; in uvoice_hls_build()
796 hls->duration, in uvoice_hls_build()
797 hls->seg_count, hls->seg_index); in uvoice_hls_build()
799 if (strlen(hls->base) <= 0) { in uvoice_hls_build()
800 memcpy(hls->base, loader->url, strlen(loader->url) + 1); in uvoice_hls_build()
801 M_LOGD("seq base %s\n", hls->base); in uvoice_hls_build()
804 if (!strncmp(hls->seg_desc, "http://", strlen("http://")) || in uvoice_hls_build()
805 !strncmp(hls->seg_desc, "https://", strlen("https://"))) { in uvoice_hls_build()
806 if (strlen(hls->seg_desc) + 1 > HTTP_URL_LEN) { in uvoice_hls_build()
810 hls->sub = loader->url; in uvoice_hls_build()
811 memset(hls->sub, 0, HTTP_URL_LEN); in uvoice_hls_build()
812 memcpy(hls->sub, hls->seg_desc, in uvoice_hls_build()
813 strlen(hls->seg_desc) + 1); in uvoice_hls_build()
814 } else if (!strncmp(hls->seg_desc, "//", strlen("//"))) { in uvoice_hls_build()
815 if (strlen(hls->seg_desc) + 1 > HTTP_URL_LEN) { in uvoice_hls_build()
821 hls->sub = loader->url + strlen("http:"); in uvoice_hls_build()
822 memset(hls->sub, 0, in uvoice_hls_build()
823 HTTP_URL_LEN - (hls->sub - loader->url)); in uvoice_hls_build()
824 if (strlen(hls->seg_desc) + 1 > in uvoice_hls_build()
825 HTTP_URL_LEN - (hls->sub - loader->url)) { in uvoice_hls_build()
829 memcpy(hls->sub, hls->seg_desc, strlen(hls->seg_desc) + 1); in uvoice_hls_build()
831 hls->sub = loader->url + strlen("https:"); in uvoice_hls_build()
832 memset(hls->sub, 0, in uvoice_hls_build()
833 HTTP_URL_LEN - (hls->sub - loader->url)); in uvoice_hls_build()
834 memcpy(hls->sub, hls->seg_desc, strlen(hls->seg_desc) + 1); in uvoice_hls_build()
847 if (strchr(hls->seg_desc, '/')) { in uvoice_hls_build()
850 ptr = hls->seg_desc + strlen(hls->seg_desc); in uvoice_hls_build()
852 seg_prefix >= hls->seg_desc; seg_prefix--) { in uvoice_hls_build()
854 prefix_len = seg_prefix - hls->seg_desc + 1; in uvoice_hls_build()
861 hls->seg_desc, prefix_len)) { in uvoice_hls_build()
870 strlen(hls->seg_desc)) { in uvoice_hls_build()
872 if (hls->fp) in uvoice_hls_build()
873 os_fclose(hls->fp); in uvoice_hls_build()
874 if (hls->content) in uvoice_hls_build()
875 snd_free(hls->content); in uvoice_hls_build()
876 snd_free(hls); in uvoice_hls_build()
877 if (loader->hls) in uvoice_hls_build()
878 loader->hls = NULL; in uvoice_hls_build()
882 hls->sub = ptr_name; in uvoice_hls_build()
884 memcpy(hls->sub, hls->seg_desc, in uvoice_hls_build()
885 strlen(hls->seg_desc) + 1); in uvoice_hls_build()
889 hls->seg_offset = snd_zalloc( in uvoice_hls_build()
890 hls->seg_count * sizeof(int), AFM_EXTN); in uvoice_hls_build()
891 if (!hls->seg_offset) { in uvoice_hls_build()
893 if (hls->fp) in uvoice_hls_build()
894 os_fclose(hls->fp); in uvoice_hls_build()
895 if (hls->content) in uvoice_hls_build()
896 snd_free(hls->content); in uvoice_hls_build()
897 snd_free(hls); in uvoice_hls_build()
898 if (loader->hls) in uvoice_hls_build()
899 loader->hls = NULL; in uvoice_hls_build()
903 hls->lock = os_mutex_new(); in uvoice_hls_build()
905 if (!loader->hls) in uvoice_hls_build()
906 loader->hls = hls; in uvoice_hls_build()
921 if (!loader->hls) { in uvoice_hls_release()
926 if (loader->hls->fp) { in uvoice_hls_release()
927 os_fclose(loader->hls->fp); in uvoice_hls_release()
931 if (loader->hls->content) { in uvoice_hls_release()
932 snd_free(loader->hls->content); in uvoice_hls_release()
936 if (loader->hls->seg_offset) { in uvoice_hls_release()
937 snd_free(loader->hls->seg_offset); in uvoice_hls_release()
941 os_mutex_free(loader->hls->lock); in uvoice_hls_release()
942 snd_free(loader->hls); in uvoice_hls_release()