Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A Twitch stream player for Windows with enhanced TLS support.
- Quality selection
- Windows 7+ compatibility
- **Enhanced TLS Client Support** - Custom TLS implementation for better compatibility with older Windows versions
- **TSReadEX Stream Enhancement** - Optional MPEG-TS stream processing for improved compatibility and quality

## TX-Queue IPC Integration for Enhanced Performance

Expand Down Expand Up @@ -80,6 +81,24 @@ The integration works as a fallback system:
1. Primary: WinHTTP (standard Windows HTTP library)
2. Fallback: Custom TLS client (when WinHTTP fails or on older systems)

## TSReadEX Stream Enhancement

Tardsplaya includes optional integration with TSReadEX for advanced MPEG-TS stream processing:

- **Stream Filtering**: Removes unwanted data like program guide information for cleaner streams
- **PID Standardization**: Remaps packet IDs to standard values for better player compatibility
- **Audio Enhancement**: Ensures consistent audio streams and handles format conversion
- **Stream Stabilization**: Processes transport streams to handle edge cases and improve reliability

### Using TSReadEX

1. Go to **Tools → Settings**
2. Enable **"TSReadEX Stream Enhancement"**
3. Configure options like removing program guide data and audio stabilization
4. Streaming will automatically use Transport Stream mode with TSReadEX processing

See [TSREADEX_INTEGRATION.md](TSREADEX_INTEGRATION.md) for detailed documentation.

## Building

Requires Visual Studio 2015 or later. The project includes all necessary TLS client components and will compile them automatically.
Expand Down
76 changes: 76 additions & 0 deletions TESTING_TSREADEX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# TSReadEX Integration Test

This document describes how to test the TSReadEX integration in Tardsplaya.

## What Was Implemented

The TSReadEX integration provides optional MPEG-TS stream enhancement with the following capabilities:

1. **Stream Filtering**: Removes unwanted data like EIT (program guide) packets
2. **PID Standardization**: Remaps packet IDs to standard values for better compatibility
3. **Audio Enhancement**: Ensures consistent audio streams and handles missing audio
4. **Stream Stabilization**: Processes transport streams to handle edge cases

## How to Test

### 1. Enable TSReadEX in Settings
1. Launch Tardsplaya
2. Go to **Tools → Settings**
3. In the "TSReadEX Stream Enhancement" section:
- ✅ Check "Enable TSReadEX processing"
- ✅ Check "Remove program guide data" (recommended)
- ✅ Check "Stabilize audio streams" (recommended)
4. Click **OK**

### 2. Test Streaming with TSReadEX
1. Enter a Twitch channel name
2. Click **Load** to fetch qualities
3. Select a quality and click **Watch**
4. Observe the log messages:
- Should show **[TS-ROUTER]** messages instead of **[TX-QUEUE]**
- Look for **"TSReadEX processor initialized"** message
- During streaming, watch for **[TSREADEX]** processing messages

### 3. Compare Performance
Test both modes to compare:

**Without TSReadEX** (TX-Queue mode):
- Disable TSReadEX in settings
- Start a stream - should show **[TX-QUEUE]** messages
- Note buffering behavior and player compatibility

**With TSReadEX** (Transport Stream mode):
- Enable TSReadEX in settings
- Start the same stream - should show **[TS-ROUTER]** messages
- Compare stream quality and player compatibility

## Expected Behavior

### With TSReadEX Enabled:
- Streaming mode: **Transport Stream** with TSReadEX processing
- Log messages indicate **[TS-ROUTER]** and **[TSREADEX]** activity
- Potentially cleaner stream data sent to media player
- Better compatibility with picky media players

### With TSReadEX Disabled:
- Streaming mode: **TX-Queue IPC** (high-performance default)
- Log messages show **[TX-QUEUE]** activity
- Direct segment streaming without additional processing

## Troubleshooting

If TSReadEX causes issues:
1. Disable it in Settings to return to TX-Queue mode
2. Check logs for **[TSREADEX]** error messages
3. Verify media player supports transport stream input
4. Some unusual stream formats may not be compatible

## Benefits Analysis

TSReadEX is most beneficial when:
- Using media players that are sensitive to stream format variations
- Experiencing audio/video sync issues with certain streams
- Wanting cleaner streams with less unnecessary data
- Need standardized PID assignments for better compatibility

The integration maintains full backward compatibility - disabling TSReadEX returns to the original high-performance TX-Queue streaming mode.
62 changes: 62 additions & 0 deletions TSREADEX_ANSWER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Can TSReadEX be used for anything?

**Yes, TSReadEX can definitely help Tardsplaya!**

## What TSReadEX Provides for Tardsplaya

TSReadEX is a sophisticated MPEG-TS processing tool that enhances Tardsplaya's streaming capabilities in several important ways:

### 1. **Better Media Player Compatibility**
- **Standardized PID assignments** work more reliably with various media players
- **Stream structure normalization** handles edge cases that might confuse players
- **Consistent packet formatting** reduces player-specific compatibility issues

### 2. **Cleaner, More Efficient Streams**
- **Removes program guide data (EIT)** that's not needed for streaming, reducing bandwidth
- **Filters unnecessary packets** to create leaner streams
- **Removes duplicate or redundant information** from transport streams

### 3. **Enhanced Audio Handling**
- **Ensures consistent audio streams** are always present (adds silent audio if missing)
- **Handles mono-to-stereo conversion** when needed
- **Stabilizes audio stream structure** for better synchronization

### 4. **Stream Stabilization**
- **Handles malformed or unusual stream formats** gracefully
- **Provides consistent transport stream structure** even from varying input sources
- **Improves reliability** with streams that have formatting inconsistencies

## How It's Integrated in Tardsplaya

The integration is **optional and user-controlled**:

1. **Settings Control**: Users can enable/disable TSReadEX processing in Tools → Settings
2. **Automatic Mode Switching**: When enabled, Tardsplaya uses Transport Stream mode with TSReadEX processing
3. **Fallback Capability**: If TSReadEX fails, falls back to original packet processing
4. **Performance Conscious**: Minimal overhead, only processes when enabled

## When TSReadEX Helps Most

TSReadEX is particularly valuable for:
- **Difficult-to-handle streams** that cause issues with standard processing
- **Media players that are sensitive** to transport stream variations
- **Users experiencing audio/video sync problems** with certain streams
- **Situations requiring maximum compatibility** across different players

## Implementation Benefits

- **Non-disruptive**: Doesn't change Tardsplaya's core functionality
- **Optional**: Users choose when they need enhanced processing
- **Maintains Performance**: Default TX-Queue mode remains unchanged for maximum speed
- **Comprehensive**: Includes all relevant TSReadEX features for streaming use cases

## Conclusion

**TSReadEX significantly enhances Tardsplaya's stream processing capabilities.** While Tardsplaya's core HLS streaming doesn't directly use MPEG-TS format, the integration provides valuable transport stream processing that:

1. Improves compatibility with media players
2. Creates cleaner, more reliable streams
3. Handles edge cases and unusual stream formats
4. Provides professional-grade stream filtering and enhancement

The integration proves that TSReadEX can indeed be very useful for Tardsplaya, specifically for its **transport stream processing capabilities** that enhance stream quality and player compatibility.
67 changes: 67 additions & 0 deletions TSREADEX_INTEGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# TSReadEX Integration Documentation

## Overview

Tardsplaya now includes optional integration with TSReadEX, a sophisticated MPEG-TS processing tool that provides stream filtering, enhancement, and stabilization capabilities.

## What is TSReadEX?

TSReadEX (https://github.com/xtne6f/tsreadex) is a tool for MPEG-TS stream selection and stabilization. It can:

- Filter and select specific services/programs from transport streams
- Standardize PID assignments for better player compatibility
- Ensure consistent audio streams (complement missing audio)
- Remove unwanted data like program guide information
- Handle audio stream manipulation (mono-to-stereo conversion)
- Stabilize stream structure for improved playback reliability

## Integration Benefits

For Tardsplaya users, TSReadEX provides:

1. **Improved Stream Compatibility**: Standardized PID assignments work better with various media players
2. **Cleaner Streams**: Removes unnecessary program guide data to reduce bandwidth
3. **Better Audio Handling**: Ensures consistent audio streams for reliable playback
4. **Enhanced Stability**: Stream processing that handles edge cases in transport stream format

## How to Enable

1. Go to **Tools → Settings**
2. In the "TSReadEX Stream Enhancement" section:
- Check **"Enable TSReadEX processing"**
- Optionally configure:
- **"Remove program guide data"** - Removes EIT data for cleaner streams (recommended)
- **"Stabilize audio streams"** - Ensures consistent audio presence (recommended)
3. Click **OK** to save settings

## When TSReadEX is Active

- Streaming mode automatically switches to **Transport Stream** mode
- TSReadEX processes the stream before sending to media player
- Log messages will show **[TS_ROUTER]** and **[TSREADEX]** entries
- Stream filtering statistics are logged periodically

## Performance Impact

- Minimal CPU overhead for stream processing
- Slightly increased memory usage for buffering
- May reduce overall bandwidth due to filtered data
- Transport Stream mode has different buffering characteristics than TX-Queue mode

## Troubleshooting

If you experience issues with TSReadEX enabled:

1. **Disable TSReadEX** in settings to return to standard TX-Queue mode
2. Check logs for **[TSREADEX]** error messages
3. Verify your media player supports transport stream input
4. Some very unusual stream formats may not be compatible

## Technical Details

- TSReadEX processes streams in the Transport Stream pipeline
- Works as optional post-processing filter
- Maintains compatibility with existing streaming infrastructure
- Automatically falls back to original packets if processing fails

The integration provides these capabilities without disrupting Tardsplaya's core functionality, allowing users to enable enhanced stream processing when needed.
49 changes: 46 additions & 3 deletions Tardsplaya.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ bool g_logAutoScroll = true;
bool g_minimizeToTray = false;
bool g_logToFile = false; // Enable logging to debug.log file

// TSReadEX settings
bool g_enableTSReadEX = false; // Enable TSReadEX stream processing
bool g_tsreadexRemoveEIT = true; // Remove program guide data
bool g_tsreadexStabilizeAudio = true; // Stabilize audio streams



// Tray icon support
Expand Down Expand Up @@ -198,6 +203,11 @@ void LoadSettings() {

// Load verbose debug setting
g_verboseDebug = GetPrivateProfileIntW(L"Settings", L"VerboseDebug", 0, iniPath.c_str()) != 0;

// Load TSReadEX settings
g_enableTSReadEX = GetPrivateProfileIntW(L"Settings", L"EnableTSReadEX", 0, iniPath.c_str()) != 0;
g_tsreadexRemoveEIT = GetPrivateProfileIntW(L"Settings", L"TSReadEXRemoveEIT", 1, iniPath.c_str()) != 0;
g_tsreadexStabilizeAudio = GetPrivateProfileIntW(L"Settings", L"TSReadEXStabilizeAudio", 1, iniPath.c_str()) != 0;
}

void SaveSettings() {
Expand Down Expand Up @@ -225,6 +235,11 @@ void SaveSettings() {

// Save verbose debug setting
WritePrivateProfileStringW(L"Settings", L"VerboseDebug", g_verboseDebug ? L"1" : L"0", iniPath.c_str());

// Save TSReadEX settings
WritePrivateProfileStringW(L"Settings", L"EnableTSReadEX", g_enableTSReadEX ? L"1" : L"0", iniPath.c_str());
WritePrivateProfileStringW(L"Settings", L"TSReadEXRemoveEIT", g_tsreadexRemoveEIT ? L"1" : L"0", iniPath.c_str());
WritePrivateProfileStringW(L"Settings", L"TSReadEXStabilizeAudio", g_tsreadexStabilizeAudio ? L"1" : L"0", iniPath.c_str());
}

void AddLog(const std::wstring& msg) {
Expand Down Expand Up @@ -922,10 +937,16 @@ void WatchStream(StreamTab& tab, size_t tabIndex) {
AddDebugLog(L"WatchStream: Creating stream thread for tab " + std::to_wstring(tabIndex) +
L", PlayerPath=" + g_playerPath + L", URL=" + url);

// TX-Queue IPC Mode is now the default streaming mode
StreamingMode mode = StreamingMode::TX_QUEUE_IPC;
// Choose streaming mode based on settings
StreamingMode mode = StreamingMode::TX_QUEUE_IPC; // Default high-performance mode

AddLog(L"[TX-QUEUE] Starting TX-Queue IPC streaming for " + tab.channel + L" (" + standardQuality + L")");
if (g_enableTSReadEX) {
// Use transport stream mode for TSReadEX processing
mode = StreamingMode::TRANSPORT_STREAM;
AddLog(L"[TS-ROUTER] Starting Transport Stream with TSReadEX for " + tab.channel + L" (" + standardQuality + L")");
} else {
AddLog(L"[TX-QUEUE] Starting TX-Queue IPC streaming for " + tab.channel + L" (" + standardQuality + L")");
}

// Start the buffering thread
tab.streamThread = StartStreamThread(
Expand Down Expand Up @@ -1278,10 +1299,27 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
CheckDlgButton(hDlg, IDC_MINIMIZETOTRAY, g_minimizeToTray ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_VERBOSE_DEBUG, g_verboseDebug ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_LOG_TO_FILE, g_logToFile ? BST_CHECKED : BST_UNCHECKED);

// Initialize TSReadEX settings
CheckDlgButton(hDlg, IDC_ENABLE_TSREADEX, g_enableTSReadEX ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TSREADEX_REMOVE_EIT, g_tsreadexRemoveEIT ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TSREADEX_STABILIZE_AUDIO, g_tsreadexStabilizeAudio ? BST_CHECKED : BST_UNCHECKED);

// Enable/disable TSReadEX sub-options based on main setting
EnableWindow(GetDlgItem(hDlg, IDC_TSREADEX_REMOVE_EIT), g_enableTSReadEX);
EnableWindow(GetDlgItem(hDlg, IDC_TSREADEX_STABILIZE_AUDIO), g_enableTSReadEX);
return TRUE;

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_ENABLE_TSREADEX:
// Enable/disable TSReadEX sub-options when main checkbox changes
{
bool enabled = IsDlgButtonChecked(hDlg, IDC_ENABLE_TSREADEX) == BST_CHECKED;
EnableWindow(GetDlgItem(hDlg, IDC_TSREADEX_REMOVE_EIT), enabled);
EnableWindow(GetDlgItem(hDlg, IDC_TSREADEX_STABILIZE_AUDIO), enabled);
}
return TRUE;
case IDC_BROWSE_PLAYER: {
OPENFILENAMEW ofn = { sizeof(ofn) };
wchar_t szFile[MAX_PATH] = { 0 };
Expand Down Expand Up @@ -1317,6 +1355,11 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
g_verboseDebug = IsDlgButtonChecked(hDlg, IDC_VERBOSE_DEBUG) == BST_CHECKED;
g_logToFile = IsDlgButtonChecked(hDlg, IDC_LOG_TO_FILE) == BST_CHECKED;

// Save TSReadEX settings
g_enableTSReadEX = IsDlgButtonChecked(hDlg, IDC_ENABLE_TSREADEX) == BST_CHECKED;
g_tsreadexRemoveEIT = IsDlgButtonChecked(hDlg, IDC_TSREADEX_REMOVE_EIT) == BST_CHECKED;
g_tsreadexStabilizeAudio = IsDlgButtonChecked(hDlg, IDC_TSREADEX_STABILIZE_AUDIO) == BST_CHECKED;

// Save settings to INI file
SaveSettings();

Expand Down
14 changes: 14 additions & 0 deletions Tardsplaya.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@
<ClCompile Include="tsduck_hls_wrapper.cpp" />
<ClCompile Include="tsduck_transport_router.cpp" />
<ClCompile Include="twitch_api.cpp" />
<ClCompile Include="tsreadex_wrapper.cpp" />
<ClCompile Include="tsreadex\aac.cpp" />
<ClCompile Include="tsreadex\huffman.cpp" />
<ClCompile Include="tsreadex\id3conv.cpp" />
<ClCompile Include="tsreadex\servicefilter.cpp" />
<ClCompile Include="tsreadex\traceb24.cpp" />
<ClCompile Include="tsreadex\util.cpp" />
<ClCompile Include="tx_queue_ipc.cpp" />
<ClCompile Include="urlencode.cpp" />
</ItemGroup>
Expand All @@ -135,6 +142,13 @@
<ClInclude Include="tsduck_hls_wrapper.h" />
<ClInclude Include="tsduck_transport_router.h" />
<ClInclude Include="twitch_api.h" />
<ClInclude Include="tsreadex_wrapper.h" />
<ClInclude Include="tsreadex\aac.hpp" />
<ClInclude Include="tsreadex\huffman.hpp" />
<ClInclude Include="tsreadex\id3conv.hpp" />
<ClInclude Include="tsreadex\servicefilter.hpp" />
<ClInclude Include="tsreadex\traceb24.hpp" />
<ClInclude Include="tsreadex\util.hpp" />
<ClInclude Include="tx_queue_ipc.h" />
<ClInclude Include="tx_queue_wrapper.h" />
<ClInclude Include="urlencode.h" />
Expand Down
3 changes: 3 additions & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#define IDC_BROWSE_PLAYER 1303
#define IDC_VERBOSE_DEBUG 1304
#define IDC_LOG_TO_FILE 1305
#define IDC_ENABLE_TSREADEX 1306
#define IDC_TSREADEX_REMOVE_EIT 1307
#define IDC_TSREADEX_STABILIZE_AUDIO 1308
#define IDC_LOAD 1101
#define IDC_QUALITIES 1102
#define IDC_WATCH 1103
Expand Down
Loading