support rotate of teacher video in one2one mode
parse width and height in record info file
正在显示
3 个修改的文件
包含
68 行增加
和
8 行删除
| @@ -606,7 +606,37 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -606,7 +606,37 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | if (_teacherFrame) { | 608 | if (_teacherFrame) { |
| 609 | - fillDestFrame(pDstFrame, _teacherFrame, 0, 0); | 609 | + if (_teacherFrame->width == SRC_W && _teacherFrame->height == SRC_H) { |
| 610 | + if (_teacherFrame->pkt_dts != 90){ | ||
| 611 | + fillDestFrame(pDstFrame, _teacherFrame, 0, 0); | ||
| 612 | + } | ||
| 613 | + else { | ||
| 614 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 615 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 616 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 617 | + fillDestFrame(pDstFrame, _teacherFrame, (SRC_W - SRC_H) / 2, 0, (SRC_W - SRC_H) / 2, 0, SRC_H, SRC_H); | ||
| 618 | + } | ||
| 619 | + } | ||
| 620 | + else if (_teacherFrame->width == SRC_H && _teacherFrame->height == SRC_W) { | ||
| 621 | + if (_teacherFrame->pkt_dts == 90){ | ||
| 622 | + fillDestFrame(pDstFrame, _teacherFrame, 0, 0); | ||
| 623 | + } | ||
| 624 | + else { | ||
| 625 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 626 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 627 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 628 | + fillDestFrame(pDstFrame, _teacherFrame, (SRC_W - SRC_H) / 2, 0, 0, (SRC_W - SRC_H) / 2, SRC_H, SRC_H); | ||
| 629 | + } | ||
| 630 | + } | ||
| 631 | + else if (_teacherFrame->width == SRC_H && _teacherFrame->height == SRC_H) { | ||
| 632 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 633 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 634 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 635 | + fillDestFrame(pDstFrame, _teacherFrame, (SRC_W - SRC_H) / 2, 0); | ||
| 636 | + } | ||
| 637 | + else { | ||
| 638 | + printf("\nresolution: %dx%d unexpected!", _studentFrame->width, _studentFrame->height); | ||
| 639 | + } | ||
| 610 | if (_studentFrame) { | 640 | if (_studentFrame) { |
| 611 | if (_studentFrame->width == SRC_W) { | 641 | if (_studentFrame->width == SRC_W) { |
| 612 | if (_studentFrame->pkt_dts != 90){ | 642 | if (_studentFrame->pkt_dts != 90){ |
| @@ -636,7 +666,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -636,7 +666,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 636 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); | 666 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); |
| 637 | } | 667 | } |
| 638 | else { | 668 | else { |
| 639 | - fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, (SRC_W - SRC_H) / 2, 0, SRC_W, SRC_H); | 669 | + fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, (SRC_W - SRC_H) / 2, 0, SRC_H, SRC_H); |
| 640 | } | 670 | } |
| 641 | } | 671 | } |
| 642 | else if (_studentFrame->width == SRC_H && _studentFrame->height == SRC_W) { | 672 | else if (_studentFrame->width == SRC_H && _studentFrame->height == SRC_W) { |
| @@ -644,7 +674,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -644,7 +674,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 644 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); | 674 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); |
| 645 | } | 675 | } |
| 646 | else { | 676 | else { |
| 647 | - fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, 0, (SRC_W - SRC_H) / 2, SRC_W, SRC_H); | 677 | + fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, 0, (SRC_W - SRC_H) / 2, SRC_H, SRC_H); |
| 648 | } | 678 | } |
| 649 | } | 679 | } |
| 650 | else if (_studentFrame->width == SRC_H && _studentFrame->height == SRC_H) { | 680 | else if (_studentFrame->width == SRC_H && _studentFrame->height == SRC_H) { |
| @@ -24,6 +24,8 @@ public: | @@ -24,6 +24,8 @@ public: | ||
| 24 | unsigned int uid; | 24 | unsigned int uid; |
| 25 | media_type m_type; | 25 | media_type m_type; |
| 26 | media_role m_role; | 26 | media_role m_role; |
| 27 | + int width; | ||
| 28 | + int height; | ||
| 27 | int rotate; //degree,0,90,180 ... | 29 | int rotate; //degree,0,90,180 ... |
| 28 | }; | 30 | }; |
| 29 | 31 | ||
| @@ -126,10 +128,12 @@ void addinfo(float t, string name, bool bstart,media_role role,unsigned int uid) | @@ -126,10 +128,12 @@ void addinfo(float t, string name, bool bstart,media_role role,unsigned int uid) | ||
| 126 | } | 128 | } |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 129 | -void addinfo(const char * name, const char * rotation){ | 131 | +void addinfo(const char * name, const char * width, const char * height, const char * rotation){ |
| 130 | int i = 0; | 132 | int i = 0; |
| 131 | for (; i < media_files.size(); i++) { | 133 | for (; i < media_files.size(); i++) { |
| 132 | if (media_files[i].name == name) { | 134 | if (media_files[i].name == name) { |
| 135 | + media_files[i].width = atoi(width); | ||
| 136 | + media_files[i].height = atoi(height); | ||
| 133 | media_files[i].rotate = atoi(rotation); | 137 | media_files[i].rotate = atoi(rotation); |
| 134 | break; | 138 | break; |
| 135 | } | 139 | } |
| @@ -141,7 +145,20 @@ void addinfo(const char * name, const char * rotation){ | @@ -141,7 +145,20 @@ void addinfo(const char * name, const char * rotation){ | ||
| 141 | } | 145 | } |
| 142 | } | 146 | } |
| 143 | 147 | ||
| 148 | +void addinfo(const char * name, const char * rotation){ | ||
| 149 | + int i = 0; | ||
| 150 | + for (; i < media_files.size(); i++) { | ||
| 151 | + if (media_files[i].name == name) { | ||
| 152 | + media_files[i].rotate = atoi(rotation); | ||
| 153 | + break; | ||
| 154 | + } | ||
| 155 | + } | ||
| 144 | 156 | ||
| 157 | + if (i == media_files.size()) | ||
| 158 | + { | ||
| 159 | + printf("\nerror ,file : %s info but not found!", name); | ||
| 160 | + } | ||
| 161 | +} | ||
| 145 | 162 | ||
| 146 | void split(string str, string separator, vector<string> &result, bool includeEmptyItem = false) { | 163 | void split(string str, string separator, vector<string> &result, bool includeEmptyItem = false) { |
| 147 | result.clear(); | 164 | result.clear(); |
| @@ -625,6 +642,8 @@ void add_media_infos() | @@ -625,6 +642,8 @@ void add_media_infos() | ||
| 625 | m.t_type = tt_start; | 642 | m.t_type = tt_start; |
| 626 | m.duration = f.end_time - f.start_time; | 643 | m.duration = f.end_time - f.start_time; |
| 627 | m.type_time = m.start_time; | 644 | m.type_time = m.start_time; |
| 645 | + m.width = f.width; | ||
| 646 | + m.height = f.height; | ||
| 628 | m.rotate = f.rotate; | 647 | m.rotate = f.rotate; |
| 629 | m.m_role = f.m_role; | 648 | m.m_role = f.m_role; |
| 630 | m.uid = f.uid; | 649 | m.uid = f.uid; |
| @@ -664,7 +683,7 @@ void add_media_infos() | @@ -664,7 +683,7 @@ void add_media_infos() | ||
| 664 | printf("\nsorted file info:"); | 683 | printf("\nsorted file info:"); |
| 665 | it = sorted_media_with_end.begin(); | 684 | it = sorted_media_with_end.begin(); |
| 666 | for (; it != sorted_media_with_end.end();it++){ | 685 | for (; it != sorted_media_with_end.end();it++){ |
| 667 | - printf("\n%2d %8.3f %s %s", it->sorted_index, it->type_time, it->name.c_str(), it->t_type == tt_start ? "start" : "end"); | 686 | + printf("\n%2d %8.3f %s %4d %4d %3d %s", it->sorted_index, it->type_time, it->name.c_str(), it->width, it->height, it->rotate, it->t_type == tt_start ? "start" : "end"); |
| 668 | } | 687 | } |
| 669 | printf("\n-------------------------\n"); | 688 | printf("\n-------------------------\n"); |
| 670 | 689 | ||
| @@ -843,9 +862,14 @@ int readfile(const char * filename, media_role role) | @@ -843,9 +862,14 @@ int readfile(const char * filename, media_role role) | ||
| 843 | } | 862 | } |
| 844 | else if (res[2] == "info") { | 863 | else if (res[2] == "info") { |
| 845 | if (res.size() > 5) { | 864 | if (res.size() > 5) { |
| 846 | - const char * pInfo = res[5].c_str(); | ||
| 847 | - if (!strncmp(pInfo, "rotation=", 9)){ | ||
| 848 | - addinfo(res[1].c_str(), pInfo + 9); | 865 | + const char * pInfoW = res[3].c_str(); |
| 866 | + const char * pInfoH = res[4].c_str(); | ||
| 867 | + const char * pInfoR = res[5].c_str(); | ||
| 868 | + if (!strncmp(pInfoW, "width=", 6) && !strncmp(pInfoH, "height=", 7) && !strncmp(pInfoR, "rotation=", 9)){ | ||
| 869 | + addinfo(res[1].c_str(), pInfoW + 6, pInfoH + 7, pInfoR + 9); | ||
| 870 | + } | ||
| 871 | + else { | ||
| 872 | + printf("error info: %s,", str); | ||
| 849 | } | 873 | } |
| 850 | } | 874 | } |
| 851 | } | 875 | } |
| @@ -855,6 +879,10 @@ int readfile(const char * filename, media_role role) | @@ -855,6 +879,10 @@ int readfile(const char * filename, media_role role) | ||
| 855 | if (!strncmp(pInfo, "rotation=", 9)){ | 879 | if (!strncmp(pInfo, "rotation=", 9)){ |
| 856 | addinfo(res[1].c_str(), pInfo + 9); | 880 | addinfo(res[1].c_str(), pInfo + 9); |
| 857 | } | 881 | } |
| 882 | + else | ||
| 883 | + { | ||
| 884 | + printf("error rotation: %s,", str); | ||
| 885 | + } | ||
| 858 | } | 886 | } |
| 859 | } | 887 | } |
| 860 | } | 888 | } |
-
请 注册 或 登录 后发表评论