SkeyePlayer RTSP Windows player adds an OSD subtitle overlay interface method. This interface is similar to the code rate information display interface method. It is a multi-OSD overlay implemented by calling the interface of the FFRender library. The call and precautions of this method are explained below;
The OSD overlay method is declared as follows:
LIB_SkeyePLAYER_API int SkeyePlayer_ShowOSD(int channelId, int show, Skeye_PALYER_OSD osd);
Among them, channelId: player channel ID, which identifies the current player instance;
show: indicates whether to display the OSD overlay, 0=unrealistic 1=display
osd: display information filling structure, defined as follows:
typedef struct tagSkeye_PALYER_OSD { char stOSD[1024]; //OSD subtitle information DWORD alpha; //Transparent to 0-255 0=transparent 255=completely opaque DWORD color; //RGB(0xf9,0xf9,0xf9) DWORD shadowcolor; //OSD background color RGB(0x4d,0x4d,0x4d) all 0 background transparent RECT rect; //OSD displays the area based on the upper right corner of the image int size; //OSD font size }Skeye_PALYER_OSD;
Note: The osd subtitle overlay is wrapped by the "\r\n" terminator, the length of a line cannot exceed 128 bytes, and the total OSD overlay cannot exceed 1024 bytes. Among them, the OSD size setting can only take effect in D3D rendering mode;
We have already understood the interface of OSD overlay, let's write a calling code to see the effect:
//OSD Example Skeye_PALYER_OSD osd; osd.alpha = 255; osd.size = 35; osd.color = RGB(255,0,255); osd.rect.left = 10; osd.rect.right = 5000; osd.rect.top = 100; osd.rect.bottom = 800; osd.shadowcolor = RGB(0,0,0); char* ss = "This is SkeyePlayer-RTSP-Win player \r\n The effect of the subtitle overlay interface! ! !\r\n by\"\\r\\n\"end of line symbol\r\n Note: The length of each line cannot exceed 128 bytes\r\n Total OSD The length cannot exceed 1024 bytes"; strcpy(osd.stOSD ,ss); SkeyePlayer_ShowOSD(m_ChannelId, 1, osd);
As shown in the above code segment, mainly by setting the parameters of the OSD_PLAYER_OSD structure, we can get the effect we want, as shown in the following figure:
(1) GDI display
[External link image transfer...(img-6MyHsd96-1652407820539)]
(2) D3D display
[External link image transfer...(img-3J1hL1gx-1652407820541)]
Comparing the two methods of OSD overlay, there is still a difference. Because D3D has hardware acceleration, we can see that OSD overlay is clearer and more efficient, while OSD is relatively rough, and the GDI interface in the original FFRender library does not support line breaks. Yes, so we need to do some technical processing, as shown in the following piece of code:
std::string sOSD = pThread->osd.stOSD; while (!sOSD.empty()) { char* subOSD = (char*)sOSD.c_str(); int nOSDLen = sOSD.length(); int sublen = 0; int nEofPos = sOSD.find("\r\n"); if (nEofPos>127) { subOSD[128] = 0; sublen = 128; } if (pThread->renderFormat == GDI_FORMAT_RGB24) { CopyRect(&osd[osdLines].rect, &pThread->osd.rect); osd[osdLines].rect.top = pThread->osd.rect.top+40*osdLines; osd[osdLines].rect.bottom = pThread->osd.rect.bottom+40*osdLines; if (nEofPos>=0) { subOSD[nEofPos] = 0; sublen = nEofPos; } } else { CopyRect(&osd[osdLines].rect, &pThread->osd.rect); osd[osdLines].rect.top = pThread->osd.rect.top+pThread->osd.size*osdLines; osd[osdLines].rect.bottom = pThread->osd.rect.bottom+pThread->osd.size*osdLines; if (nEofPos>=0) { subOSD[nEofPos] = 0; sublen = nEofPos; } } MByteToWChar(subOSD, osd[osdLines].string, sizeof(osd[osdLines].string)/sizeof(osd[osdLines].string[0])); osd[osdLines].color = pThread->osd.color; osd[osdLines].shadowcolor = pThread->osd.shadowcolor; osd[osdLines].alpha = pThread->osd.alpha; osdLines++; if (nEofPos>=0) { sOSD = subOSD+nEofPos+2; } else { sOSD = ""; } }
Briefly describe the above code, that is: find the "\r\n" terminator as an OSD message, and an OSD cannot exceed 128 bytes for line breaks, and the line height of line breaks is determined by size, because GDI does not support size Size setting, so we gave a fixed value of 40, of course, it can be adjusted for compactness or larger line spacing.
In addition, the current version of SkeyePalyer RTSP Windows player only supports soft decoding OSD overlay display, hard decoding is not yet supported.