Changeset 41345


Ignore:
Timestamp:
12/03/17 18:10:53 (6 years ago)
Author:
obi
Message:

libeplayer3 / titan add internal subs support and srt listing

Location:
titan
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • titan/libeplayer3/Makefile.am

    r40363 r41345  
    11AUTOMAKE_OPTIONS = subdir-objects
    2 AM_CFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
     2AM_CFLAGS = -Wall -Wno-parentheses -Wno-format -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
    33
    44CXXFLAGS = -Wall
  • titan/libeplayer3/container/container_ffmpeg.c

    r41314 r41345  
    210210/* MISC Functions                */
    211211/* ***************************** */
     212
     213//extern void dvbsub_ass_write(AVCodecContext *c, AVSubtitle *sub, int pid);
     214
     215//SubtitleOut_t subOut;
     216//SubtitleOut_t *subOut  = NULL;
     217
     218    uint32_t         tmptrackId;
     219//    uint8_t         *tmpdata;
     220    char         *tmpdata;
     221
     222    uint32_t         tmplen;
     223    int64_t          tmppts;
     224    int64_t          tmpduration; // duration in miliseconds
     225    char            *tmptype;
     226        int                     enablesub = 0;
     227
     228void dvbsub_ass_write(Context_t *context, AVCodecContext *c, AVSubtitle *sub, int pid, AVPacket *packet)
     229{
     230   unsigned int i;
     231
     232   ffmpeg_printf(0, "format %d\n", sub->format);
     233   ffmpeg_printf(0, "start_display_time %d\n", sub->start_display_time);
     234   ffmpeg_printf(0, "end_display_time %d\n", sub->end_display_time);
     235   ffmpeg_printf(0, "num_rects %d\n", sub->num_rects);
     236   //ffmpeg_printf(0, "pts %lld\n", sub->pts);
     237
     238   for (i = 0; i < sub->num_rects; i++)
     239   {
     240
     241                ffmpeg_printf(0, "x %d\n", sub->rects[i]->x);
     242                ffmpeg_printf(0, "y %d\n", sub->rects[i]->y);
     243                ffmpeg_printf(0, "w %d\n", sub->rects[i]->w);
     244                ffmpeg_printf(0, "h %d\n", sub->rects[i]->h);
     245                ffmpeg_printf(0, "nb_colors %d\n", sub->rects[i]->nb_colors);
     246                ffmpeg_printf(0, "type %d\n", sub->rects[i]->type);
     247                ffmpeg_printf(0, "text %s\n", sub->rects[i]->text);
     248                ffmpeg_printf(0, "ass %s\n", sub->rects[i]->ass);
     249               
     250               
     251                ffmpeg_printf(0, "packet->data %s\n", packet->data);
     252                ffmpeg_printf(0, "packet->data[0] %x\n", packet->data[0]);
     253                ffmpeg_printf(0, "packet->data[1] %x\n", packet->data[1]);
     254
     255                subtext = ostrcat(subtext, (char *)sub->rects[i]->ass, 1, 0);   
     256
     257                int ret, horIni, minIni, secIni, milIni, horFim, minFim, secFim, milFim;
     258                double Duration = 0;
     259                unsigned long long int Pts = 0;
     260
     261                ret = sscanf((char *)sub->rects[i]->ass, "Dialogue: 0,%d:%d:%d.%d,%d:%d:%d.%d,", &horIni, &minIni, &secIni, &milIni, &horFim, &minFim, &secFim, &milFim);
     262
     263                if (ret!=8) continue; /* Data is not in correct format */
     264                ffmpeg_printf(0, "ret %d\n", ret);
     265
     266                ffmpeg_printf(0, "horIni %d\n", horIni);
     267                ffmpeg_printf(0, "minIni %d\n", minIni);
     268                ffmpeg_printf(0, "secIni %d\n", secIni);
     269                ffmpeg_printf(0, "milIni %d\n", milIni);
     270
     271                ffmpeg_printf(0, "horFim %d\n", horFim);
     272                ffmpeg_printf(0, "minFim %d\n", minFim);
     273                ffmpeg_printf(0, "secFim %d\n", secFim);
     274                ffmpeg_printf(0, "milFim %d\n", milFim);
     275/*
     276                Pts = (horIni*3600 + minIni*60 + secIni)*1000 + milIni;
     277                Duration = ((horFim*3600 + minFim*60 + secFim) * 1000  + milFim - Pts) / 1000.0;
     278                ffmpeg_printf(0, "new Pts %llu\n", Pts);
     279                ffmpeg_printf(0, "new Duration %f\n", Duration);
     280
     281*/
     282                tmppts = (horIni*3600 + minIni*60 + secIni)*1000 + milIni;
     283                tmpduration = ((horFim*3600 + minFim*60 + secFim) * 1000  + milFim - Pts) / 1000.0;
     284                tmpdata = packet->data;
     285
     286                ffmpeg_printf(0, "new Pts %llu\n", tmppts);
     287                ffmpeg_printf(0, "new Duration %d\n", tmpduration);
     288                ffmpeg_printf(0, "new Data %s\n", tmpdata);
     289
     290                // pict ->AVPicture
     291   }
     292}
     293
     294//int ReadSubtitle(Context_t *context, const char *filename, const char *format, int pid)
     295int ReadSubtitle(Context_t *context, const char *filename, char *format, int pid)
     296{
     297        int ret = 0;
     298        const char *lastDot = strrchr(filename, '.');
     299        if (!lastDot)
     300                return ret;
     301        char subfile[strlen(filename) + strlen(format)];
     302        strcpy(subfile, filename);
     303        strcpy(subfile + (lastDot + 1 - filename), format);
     304
     305        if (access(subfile, R_OK))
     306                return ret;
     307
     308        AVFormatContext *subavfc = avformat_alloc_context();
     309        int err = avformat_open_input(&subavfc, subfile, av_find_input_format(format), 0);
     310//      if (averror(err, avformat_open_input)) {
     311        if (err != 0)
     312    {
     313                avformat_free_context(subavfc);
     314                return ret;
     315        }
     316
     317        avformat_find_stream_info(subavfc, NULL);
     318        if (subavfc->nb_streams != 1) {
     319                avformat_free_context(subavfc);
     320                return ret;
     321        }
     322
     323        AVCodecContext *c = subavfc->streams[0]->codec;
     324        AVCodec *codec = avcodec_find_decoder(c->codec_id);
     325        if (!codec) {
     326                avformat_free_context(subavfc);
     327                return ret;
     328        }
     329
     330        err = avcodec_open2(c, codec, NULL);
     331//      if (averror(err, avcodec_open2)) {
     332        if (err != 0)
     333    {
     334                avformat_free_context(subavfc);
     335                return ret;
     336        }
     337
     338        AVPacket packet;
     339        av_init_packet(&packet);
     340
     341        free(subtext), subtext = NULL;
     342
     343        while (av_read_frame(subavfc, &packet) > -1) {
     344                AVSubtitle sub;
     345                memset(&sub, 0, sizeof(sub));
     346                int got_sub = 0;
     347                avcodec_decode_subtitle2(c, &sub, &got_sub, &packet);
     348                if (got_sub)
     349                {
     350                        dvbsub_ass_write(context, c, &sub, pid, &packet);
     351
     352                        char* tmpstr = NULL;
     353                        tmpstr = ostrcat(tmpstr, "duration=", 1, 0);
     354                        tmpstr = ostrcat(tmpstr, ollutoa(tmpduration), 1, 1);
     355                        tmpstr = ostrcat(tmpstr, ";pts=", 1, 0);;
     356                        tmpstr = ostrcat(tmpstr, ollutoa(tmppts), 1, 0);;
     357                        tmpstr = ostrcat(tmpstr, ";trackid=", 1, 0);;
     358                        tmpstr = ostrcat(tmpstr, oitoa(tmptrackId), 1, 0);
     359                        tmpstr = ostrcat(tmpstr, ";subtext=", 1, 0);;
     360                        tmpstr = ostrcat(tmpstr, tmpdata, 1, 0);;
     361                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);;
     362
     363                        subtext = ostrcat(subtext, tmpstr, 1, 0);
     364                        free(tmpstr), tmpstr = NULL;
     365
     366                        tmpduration = 0;
     367                        tmppts = 0;
     368                        tmptrackId = 0;
     369
     370
     371                }
     372                av_free_packet(&packet);
     373        }
     374
     375//      free(subtext), subtext = NULL;
     376
     377        avcodec_close(c);
     378        avformat_close_input(&subavfc);
     379        avformat_free_context(subavfc);
     380
     381    ffmpeg_printf(1, "format=%s\n", format);
     382    ffmpeg_printf(1, "pid=%d\n", pid);
     383
     384        if(pid != -1)
     385        {
     386                Track_t Subtitle;
     387                memset(&Subtitle, 0, sizeof(Subtitle));
     388                Subtitle.Name = ostrcat("External Sub: ", format, 0, 0);
     389                if(ostrstr(format, "srt") != NULL)
     390                        Subtitle.Encoding = "S_TEXT/SRT";
     391                else if(ostrstr(format, "ass") != NULL)
     392                        Subtitle.Encoding = "S_TEXT/ASS";
     393                else if(ostrstr(format, "ssa") != NULL)
     394                        Subtitle.Encoding = "S_TEXT/SSA";
     395                else if(ostrstr(format, "sub") != NULL)
     396                        Subtitle.Encoding = "S_TEXT/SUBRIP";
     397                else if(ostrstr(format, "idx") != NULL)
     398                        Subtitle.Encoding = "S_TEXT/SUBRIP";
     399                Subtitle.File       = strdup(subfile); 
     400                Subtitle.Id = pid,
     401                context->manager->subtitle->Command(context, MANAGER_ADD, &Subtitle);
     402        }
     403
     404//      Track track;
     405//      track.title = format;
     406//      track.is_static = 1;
     407//      track.pid = pid;
     408//      player->manager.addSubtitleTrack(track);
     409        return 1;
     410}
     411
     412int ReadSubtitles(Context_t *context, const char *filename)
     413{
     414        int ret = 0;
     415        if (strncmp(filename, "file://", 7))
     416                return ret;
     417        filename += 7;
     418        ret |= ReadSubtitle(context, filename, "srt", 0xFFFF);
     419        ret |= ReadSubtitle(context, filename, "ass", 0xFFFE);
     420        ret |= ReadSubtitle(context, filename, "ssa", 0xFFFD);
     421        ret |= ReadSubtitle(context, filename, "sub", 0xFFFC);
     422        ret |= ReadSubtitle(context, filename, "idx", 0xFFFB);
     423        return ret;
     424}
     425
    212426
    213427static void ffmpeg_silen_callback(void * avcl, int level, const char * fmt, va_list vl)
     
    11641378                if (duration > 0)
    11651379                {
     1380printf("[LIBEPLAYER3/FFMPEGThread] start\n");
     1381
    11661382                    SubtitleOut_t subOut;
    11671383                    memset(&subOut, 0, sizeof(subOut));
     
    11701386                    subOut.pts = pts;
    11711387                    subOut.durationMS = duration;
     1388
     1389                                        tmptrackId = pid;
     1390                                        tmpdata = (uint8_t *)packet.data;
     1391//                                      tmpdata = (uint8_t *)&packet.data;
     1392                                        //tmplen;
     1393                                        tmppts = pts;
     1394                                        tmpduration = duration;
     1395                                        tmpdata = ostrcat(subOut.data, NULL, 0, 0);
     1396
     1397                                        //*tmptype;
     1398printf("[LIBEPLAYER3/FFMPEGThread] set tmpdata=%s\n", tmpdata);
     1399printf("[LIBEPLAYER3/FFMPEGThread] set tmppts=%lld\n", tmppts);
     1400printf("[LIBEPLAYER3/FFMPEGThread] set tmpduration=%lld\n", tmpduration);
     1401
     1402
    11721403                    if (context->output->subtitle->Write(context, &subOut) < 0)
    11731404                    {
    11741405                        ffmpeg_err("writing data to teletext fifo failed\n");
    11751406                    }
     1407
     1408                        char* tmpstr = NULL;
     1409                        tmpstr = ostrcat(tmpstr, "duration=", 1, 0);
     1410                        tmpstr = ostrcat(tmpstr, ollutoa(tmpduration), 1, 1);
     1411                        tmpstr = ostrcat(tmpstr, ";pts=", 1, 0);;
     1412                        tmpstr = ostrcat(tmpstr, ollutoa(tmppts), 1, 0);;
     1413                        tmpstr = ostrcat(tmpstr, ";trackid=", 1, 0);;
     1414                        tmpstr = ostrcat(tmpstr, oitoa(tmptrackId), 1, 0);
     1415                        tmpstr = ostrcat(tmpstr, ";subtext=", 1, 0);;
     1416                        tmpstr = ostrcat(tmpstr, tmpdata, 1, 0);;
     1417
     1418                        free(subtext), subtext = NULL;
     1419                        subtext = ostrcat(subtext, tmpstr, 1, 0);
     1420                        free(tmpstr), tmpstr = NULL;
     1421
     1422//                      tmpduration = 0;
     1423                        tmppts = 0;
     1424                        tmptrackId = 0;
     1425
     1426
     1427printf("[LIBEPLAYER3/FFMPEGThread] set subtext: %s\n", subtext);
     1428
    11761429                }
    11771430            }
     
    19242177    isContainerRunning = 1;
    19252178    res = container_ffmpeg_update_tracks(context, playFilesNames->szFirstFile, 1);
     2179
     2180        ffmpeg_printf(1, "aaaaaaaaaaaaa\n");
     2181        ReadSubtitles(context, playFilesNames->szFirstFile);
     2182    ffmpeg_printf(1, "bbbbbbbbbbbbbbb\n");
    19262183    return res;
    19272184}
     
    29973254    int64_t sec = -5;
    29983255    context->playback->Command(context, PLAYBACK_SEEK, (void*)&sec);
     3256        enablesub = 1;
     3257    return cERR_CONTAINER_FFMPEG_NO_ERROR;
     3258}
     3259
     3260static int32_t container_ffmpeg_get_subtext(Context_t* context, char ** data)
     3261//static int32_t container_ffmpeg_get_subtext(Context_t* context, SubtitleOut_t input)
     3262//static int32_t container_ffmpeg_get_subtext(Context_t* context, void **data)
     3263//static int32_t container_ffmpeg_get_subtext(Context_t* context, SubtitleOut_t **data)
     3264//static int32_t container_ffmpeg_get_subtext(Context_t* context, SubtitleOut_t *data)
     3265//static int32_t container_ffmpeg_get_subtext(Context_t* context, SubtitleOut_t ** data)
     3266{
     3267
     3268printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start\n");
     3269
     3270//if(tmpduration != 0 && subtext != NULL)
     3271if(enablesub == 1 && subtext != NULL)
     3272{
     3273        printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] set data\n");
     3274/*
     3275        char* tmpstr = NULL;
     3276        tmpstr = ostrcat("duration=", NULL, 0, 0);
     3277        tmpstr = ostrcat(tmpstr, ollutoa(tmpduration), 1, 1);
     3278        tmpstr = ostrcat(tmpstr, ";pts=", 1, 0);;
     3279        tmpstr = ostrcat(tmpstr, ollutoa(tmppts), 1, 0);;
     3280        tmpstr = ostrcat(tmpstr, ";trackid=", 1, 0);;
     3281        tmpstr = ostrcat(tmpstr, oitoa(tmptrackId), 1, 0);
     3282        tmpstr = ostrcat(tmpstr, ";subtext=", 1, 0);;
     3283        tmpstr = ostrcat(tmpstr, subtext, 1, 0);;
     3284        *data = ostrcat(tmpstr, NULL, 0, 0);
     3285        free(tmpstr), tmpstr = NULL;
     3286        free(subtext), subtext = NULL;
     3287        tmpduration = 0;
     3288        tmppts = 0;
     3289        tmptrackId = 0;
     3290*/
     3291        *data = ostrcat(subtext, NULL, 0, 0);
     3292        free(subtext), subtext = NULL;
     3293
     3294}
     3295
     3296
     3297
     3298//*data = ostrcat("duration=", olutoa(tmpduration), 0, 1);
     3299//*data = ostrcat(data, ";subtext=", 1, 0);
     3300//*data = ostrcat(data, "subtext", 1, 0);
     3301
     3302//*data = ostrcat(subtext, NULL, 0, 0);
     3303
     3304
     3305
     3306
     3307/*
     3308                                        SubtitleOut_t subOut;
     3309                    memset(&subOut, 0, sizeof(subOut));
     3310                    subOut.trackId = tmptrackId;
     3311                    subOut.data = (uint8_t *)subtext;
     3312                    subOut.pts = tmppts;
     3313                    subOut.durationMS = tmpduration;
     3314printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start1\n");
     3315memset(&data, 0, sizeof(data));
     3316printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start1a\n");
     3317
     3318*data = subOut;
     3319
     3320//
     3321
     3322//                    SubtitleOut_t subOut;
     3323printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start2\n");
     3324
     3325                    memset(&data, 0, sizeof(data));
     3326printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start3\n");
     3327
     3328printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] tmptrackId=%d\n", tmptrackId);
     3329printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] data.trackId=%d\n", data->trackId);
     3330                                          data->trackId = tmptrackId;
     3331//                    subOut.data = (uint8_t *)packet.data;
     3332printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start3\n");
     3333
     3334                    data->data = (uint8_t *)subtext;
     3335printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start4\n");
     3336
     3337                    data->pts = tmppts;
     3338printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] start5\n");
     3339
     3340                    data->durationMS = tmpduration;
     3341
     3342printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check subtext=%s\n", subtext);
     3343printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check tmpdata=%s\n", tmpdata);
     3344printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check data->data=%s\n", data->data);
     3345
     3346printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check tmppts=%lld\n", tmppts);
     3347printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check data->pts=%lld\n", data->pts);
     3348
     3349printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check tmpduration=%lld\n", tmpduration);
     3350printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] check data->durationMS=%lld\n", data->durationMS);
     3351*/
     3352printf("[LIBEPLAYER3/container_ffmpeg_get_subtext] end\n");
     3353
     3354/*
     3355SubtitleOut_t *out  = NULL;
     3356out = (SubtitleOut_t*) data;
     3357
     3358printf("##########################\n");
     3359printf("void *data.data: %s\n", out->data);
     3360//printf("void *data.pts: %lld\n", &data->pts);
     3361//printf("void *data.duration: %lld\n", &data->durationMS);
     3362printf("##########################\n");
     3363*/
     3364//      *data = (char *)packet->data;
     3365//      char* subtext = NULL;
     3366//      *data = ostrcat(subtext, NULL, 0, 0);
     3367//      SubtitleOut_t subOut = input;
     3368//      subOut1 = subOut;
     3369//      SubtitleOut_t *out  = NULL;
     3370//      SubtitleOut_t subOut = (SubtitleOut_t*) data;
     3371
     3372//      SubtitleOut_t *subOut  = NULL;
     3373//       *subOut;
     3374//      SubtitleOut_t *subOut = (SubtitleOut_t*) data;
     3375//      SubtitleOut_t *subOut = (SubtitleOut_t*) data;
     3376//SubtitleOut_t*
     3377
     3378
     3379//data = &subOut;
     3380
     3381//printf("555 data: %s\n", (char*)data->data);
     3382
     3383
     3384//      SubtitleOut_t *subOut;
     3385//      subOut = (SubtitleOut_t*) data;
     3386
     3387//      SubtitleOutputDef_t* out = (SubtitleOutputDef_t*)argument;
     3388
     3389//      printf("333subOut.data: %s\n", subOut.data);
     3390/*
     3391
     3392printf("##########################\n");
     3393
     3394printf("data: %s\n", tmpdata);
     3395printf("pts: %lld\n", tmppts);
     3396printf("duration: %lld\n", tmpduration);
     3397
     3398printf("subtext1: %s\n", subtext);
     3399printf("subtext2: %d\n", subtext);
     3400printf("##########################\n");
     3401printf("subOut.data: %s\n", *data->data);
     3402printf("subOut.pts: %lld\n", data.pts);
     3403printf("subOut.durationMS: %lld\n", data.durationMS);
     3404printf("##########################\n");
     3405
     3406
     3407                    SubtitleOut_t subOut;
     3408                    memset(&subOut, 0, sizeof(subOut));
     3409                    subOut.trackId = tmptrackId;
     3410//                    subOut.data = (uint8_t *)packet.data;
     3411                    subOut.data = (uint8_t *)subtext;
     3412
     3413                    subOut.pts = tmppts;
     3414                    subOut.durationMS = tmpduration;
     3415
     3416printf("subOut.data: %s\n", subOut.data);
     3417printf("subOut.pts: %lld\n", subOut.pts);
     3418printf("subOut.durationMS: %lld\n", subOut.durationMS);
     3419
     3420
     3421*data = (SubtitleOut_t*)&subOut;
     3422data = &subOut;
     3423
     3424printf("data.durationMS: %lld\n", (void*)data->durationMS);
     3425
     3426
     3427//printf("data.data: %s\n", data->data);
     3428
     3429printf("##########################\n");
     3430
     3431//printf("22subOut2.data: %s\n", subOut2.data);
     3432//printf("22ubOut2.data: %d\n", subOut2.data);
     3433*/
    29993434    return cERR_CONTAINER_FFMPEG_NO_ERROR;
    30003435}
     
    30743509       command != CONTAINER_GET_BUFFER_SIZE &&
    30753510       command != CONTAINER_GET_BUFFER_STATUS &&
    3076        command != CONTAINER_STOP_BUFFER &&
     3511       command != CONTAINER_STOP_BUFFER &&
     3512           command != CONTAINER_GET_SUBTEXT &&
    30773513       command != CONTAINER_INIT && !avContextTab[0])
    30783514    {
     
    31723608            ret = container_stop_buffer();
    31733609            break;
     3610    }
     3611    case CONTAINER_GET_SUBTEXT:
     3612    {
     3613printf("[LIBEPLAYER3/Command] start\n");
     3614
     3615        ret = container_ffmpeg_get_subtext(context, (char **)argument);
     3616
     3617//        ret = container_ffmpeg_get_subtext(context, (SubtitleOut_t **)argument);
     3618
     3619//              (SubtitleOut_t *)argument;
     3620//              memset(&argument, 0, sizeof(argument));
     3621
     3622//        ret = container_ffmpeg_get_subtext(context, SubtitleOut_t ** argument);
     3623
     3624printf("[LIBEPLAYER3/Command] end\n");
     3625//              data = ostrcat(subtext, NULL, 0, 0);
     3626//              (char **)argument = subtext;
     3627//argument = (void**)&subOut;
     3628
     3629/*
     3630//      SubtitleOutputDef_t* out = (SubtitleOutputDef_t*)argument;
     3631
     3632//printf("333subOut.data: %s\n", subOut.dat
     3633
     3634
     3635 //       ret = container_ffmpeg_get_subtext(context, (SubtitleOut_t)argument);
     3636
     3637                    SubtitleOut_t subOut;
     3638                    memset(&subOut, 0, sizeof(subOut));
     3639                    subOut.trackId = tmptrackId;
     3640//                    subOut.data = (uint8_t *)packet.data;
     3641                    subOut.data = (uint8_t *)subtext;
     3642
     3643                    subOut.pts = tmppts;
     3644                    subOut.durationMS = tmpduration;
     3645printf("##########################\n");
     3646printf("subOut.data: %s\n", subOut.data);
     3647printf("subOut.pts: %lld\n", subOut.pts);
     3648printf("subOut.duration: %lld\n", subOut.durationMS);
     3649printf("##########################\n");
     3650 
     3651       ret = container_ffmpeg_get_subtext(context, (void*)&subOut);
     3652//              *((SubtitleOut_t*)argument) = subOut;
     3653argument = (void*)&subOut;
     3654
     3655
     3656                    SubtitleOut_t argument;
     3657                    memset(&argument, 0, sizeof(argument));
     3658                    argument.trackId = tmptrackId;
     3659//                    subOut.data = (uint8_t *)packet.data;
     3660                    argument.data = (uint8_t *)subtext;
     3661
     3662                    argument.pts = tmppts;
     3663                    argument.durationMS = tmpduration;
     3664printf("##########################\n");
     3665printf("argument.data: %s\n", argument.data);
     3666printf("argument.pts: %lld\n", argument.pts);
     3667printf("argument.duration: %lld\n", argument.durationMS);
     3668printf("##########################\n");
     3669 
     3670       ret = container_ffmpeg_get_subtext(context, (void**)&argument);
     3671//              *((SubtitleOut_t*)argument) = subOut;
     3672//argument = (void**)&subOut;
     3673*/
     3674
     3675        break;
    31743676    }
    31753677    //obi (end)
  • titan/titan/play.h

    r40446 r41345  
    17171717                                }
    17181718#else
     1719                                getsubtext();
    17191720                                playinfobarcount++;
    17201721                                if(playinfobarstatus > 0)
     
    17501751                                        }
    17511752                                }
    1752                
     1753
     1754                                if(rcret == getrcconfigint("rchelp", NULL))
     1755                                        printf("getsubtext: %s\n", getsubtext());
     1756
     1757
    17531758                                if(rcret == getrcconfigint("rcpip", NULL))
    17541759                                {
  • titan/titan/player.h

    r40898 r41345  
    242242int subtitleflag = 0;
    243243char *subtext = NULL;
     244#else
     245struct stimerthread* subtitlethread = NULL;
     246uint32_t buf_pos_ms = 0;
     247uint32_t duration_ms = 0;
     248int subtitleflag = 0;
     249char *subtext = NULL;
    244250#endif
    245251
     
    906912
    907913#ifdef EPLAYER4
     914void playersubtitle_thread()
     915{
     916        struct skin* framebuffer = getscreen("framebuffer");
     917        struct skin* subtitle = getscreen("gstsubtitle");
     918        char* bg = NULL;
     919        int count = 0;
     920       
     921        subtitle->bgcol = -1;
     922       
     923        setnodeattr(subtitle, framebuffer, 0);
     924        bg = savescreen(subtitle);
     925       
     926        while(subtitlethread->aktion != STOP)
     927        {
     928                if(duration_ms != 0)
     929                {
     930                        count = 0;
     931                        changetext(subtitle, subtext);
     932                        count = duration_ms / 100;
     933                        drawscreen(subtitle, 0, 0);
     934                        while(count > 0 && subtitlethread->aktion != STOP)
     935                        {
     936                                usleep(100000);
     937                                count = count - 1;
     938                        }
     939                        changetext(subtitle, " ");
     940                        drawscreen(subtitle, 0, 0);
     941                        duration_ms = 0;
     942                }
     943                else
     944                        usleep(100000);
     945        }
     946        free(subtext); subtext = NULL;
     947        restorescreen(bg, subtitle);
     948        blitfb(0);
     949        subtitlethread = NULL;
     950}
     951#else
    908952void playersubtitle_thread()
    909953{
     
    12241268//                      if(ostrcmp(getconfig("av_ac3mode", NULL), "downmix") == 0)
    12251269#ifndef MIPSEL
     1270                        printf("status.downmix; %d\n", status.downmix);
     1271
     1272
     1273                        char* downmix = readfiletomem(getconfig("ac3dev", NULL), 1);
     1274printf("ac3dev: %s\n",getconfig("ac3dev", NULL));
     1275printf("downmix: %s\n",downmix);
     1276                        if(ostrcmp(downmix, "passthrough") == 0)
     1277                                status.downmix = 0;
     1278                        else
     1279                                status.downmix = 1;
     1280
     1281printf("status.downmix: %d\n",status.downmix);
     1282sleep(5);
    12261283                        if(status.downmix == 1)
    12271284                        {
     
    36083665#endif
    36093666
    3610 #endif
     3667char* getsubtext()
     3668{
     3669        char* tmpstr = NULL;
     3670        if(player && player->container && player->container->selectedContainer)
     3671                player->container->selectedContainer->Command(player, CONTAINER_GET_SUBTEXT, (void*)&tmpstr);
     3672
     3673
     3674//duration = oregex(".*([0-9]{8,8}.*[0-9]{4,4}).*", subtext);
     3675//duration = oregex(".*duration=(.*);.*", subtext);
     3676
     3677char* duration = oregex(".*duration=(.*);pts=.*", tmpstr);
     3678printf("[TITAN/getsubtext] duration %s\n", duration);
     3679if(duration != NULL)
     3680{
     3681        printf("[TITAN/getsubtext] duration %d\n", atoi(duration));
     3682        duration_ms = atoi(duration);
     3683}
     3684
     3685char* pts = oregex(".*;pts=(.*);trackid=.*", tmpstr);
     3686printf("[TITAN/getsubtext] pts %s\n", pts);
     3687if(pts != NULL)
     3688        printf("[TITAN/getsubtext] pts %d\n", atoi(pts));
     3689
     3690char* trackid = oregex(".*;trackid=(.*);trackid=.*", tmpstr);
     3691printf("[TITAN/getsubtext] trackid %s\n", trackid);
     3692if(trackid != NULL)
     3693        printf("[TITAN/getsubtext] trackid %d\n", atoi(trackid));
     3694
     3695subtext = oregex(".*;subtext=(.*).*", tmpstr);
     3696printf("[TITAN/getsubtext] subtext %s\n", subtext);
     3697
     3698        if(subtitlethread == NULL)
     3699                subtitlethread = addtimer(&playersubtitle_thread, START, 10000, 1, NULL, NULL, NULL);
     3700
     3701
     3702/*
     3703duration=
     3704duration=", ollutoa(tmpduration), 0, 1);
     3705tmpstr = ostrcat(tmpstr, ";pts=", 1, 0);;
     3706tmpstr = ostrcat(tmpstr, ollutoa(tmppts), 1, 0);;
     3707tmpstr = ostrcat(tmpstr, ";trackid=", 1, 0);;
     3708tmpstr = ostrcat(tmpstr, ollutoa(tmptrackId), 1, 0);
     3709tmpstr = ostrcat(tmpstr, ";subtext=", 1, 0);;
     3710tmpstr = ostrcat(tmpstr, subtext, 1, 0);
     3711
     3712        running_pts = pos / 11111LL;
     3713        decoder_ms = running_pts / 90;
     3714               
     3715        if(subtitlethread == NULL)
     3716                subtitlethread = addtimer(&playersubtitle_thread, START, 10000, 1, NULL, NULL, NULL);
     3717
     3718*/
     3719/*
     3720        SubtitleOut_t *data;
     3721printf("[TITAN/getsubtext start]\n");
     3722        if(player && player->container && player->container->selectedContainer)
     3723//              player->container->selectedContainer->Command(player, CONTAINER_GET_SUBTEXT, (void*)&data);
     3724                player->container->selectedContainer->Command(player, CONTAINER_GET_SUBTEXT, (void*)data);
     3725
     3726   if (data == NULL)
     3727        return NULL;
     3728printf("[TITAN/getsubtext] 2\n");
     3729
     3730printf("data.data: %s\n", &data->data);
     3731
     3732printf("data.data: %s\n", data->data);
     3733printf("data.pts: %lld\n", data->pts);
     3734printf("data.duration: %lld\n", data->durationMS);
     3735
     3736SubtitleOut_t *data;
     3737printf("111111111111111\n");
     3738
     3739
     3740        if(player && player->container && player->container->selectedContainer)
     3741                player->container->selectedContainer->Command(player, CONTAINER_GET_SUBTEXT, (void*)data);
     3742//              player->container->selectedContainer->Command(player, CONTAINER_GET_SUBTEXT, (void*)data);
     3743
     3744printf("222222222222222\n");
     3745
     3746   if (data == NULL)
     3747        return NULL;
     3748printf("-------------------------------------\n");
     3749
     3750printf("titan &data.data %s\n", (char*)&data->data);
     3751
     3752SubtitleOut_t *out  = NULL;
     3753printf("333333333333333\n");
     3754
     3755out = (SubtitleOut_t*) data;
     3756printf("444444444444444\n");
     3757
     3758printf("out.duration: %lld\n", out->durationMS);
     3759printf("555555555555555\n");
     3760*/
     3761/*
     3762printf(out->pts);
     3763printf("444444444444444\n");
     3764
     3765printf(out->data);
     3766printf("444444444444444\n");
     3767
     3768
     3769printf("out.pts: %u\n", out->pts);
     3770printf("out1.data: %u\n", out->data);
     3771printf("out2.data: %d\n", out->data);
     3772
     3773
     3774char *Encoding      = NULL;
     3775printf("Encoding:%s Text:%s Len:%d\n", Encoding, (char*) out->data, out->len);
     3776printf("555555555555555\n");
     3777printf("-------------------------------------\n");
     3778
     3779printf("data.pts: %lld\n", data->pts);
     3780printf("data.durationMS: %lld\n", data->durationMS);
     3781printf("data1: %lld\n", data->data);
     3782printf("data2: %d\n", data->data);
     3783printf("data3: %s\n", data->data);
     3784printf("data4: %s\n", (char*)data->data);
     3785printf("data5: %s\n", (char*)data->data);
     3786printf("-------------------------------------\n");
     3787
     3788*/
     3789/*
     3790        struct skin* framebuffer = getscreen("framebuffer");
     3791        struct skin* subtitle = getscreen("gstsubtitle");
     3792
     3793//      changetext(subtitle, (char*) data->data);
     3794        changetext(subtitle, subtext);
     3795        drawscreen(subtitle, 0, 0);
     3796*/
     3797        return subtext;
     3798}
     3799
Note: See TracChangeset for help on using the changeset viewer.